comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Problem from a Newbie
Date: Wed, 14 Jan 2004 05:49:29 GMT
Date: 2004-01-14T05:49:29+00:00	[thread overview]
Message-ID: <JL4Nb.47031$5V2.65539@attbi_s53> (raw)
In-Reply-To: 4003b00c_2@news.tm.net.my

In addition to the other comments...
You don't need to convert degrees to radians as you have done.  There is a
version of sin in Ada.Numerics.Elementary_Functions that takes a second
value as the number of units in a cycle.  So instead of using:

  sin( X * 2.0 * Pi / 360.0 )

You can use

  sin( X, 360.0 )

Which (I think) reads a lot cleaner.

Steve
(The Duck)

"Cecilia Chew" <cecilia@nowhere.com> wrote in message
news:4003b00c_2@news.tm.net.my...
> Hello All,
> I'm a newbie in Ada. There are a lot of question mark in my mind. I'm
> now doing a simple program and the desired output is a signal wave as
below.
>
> *      **      **      *
>   *    *  *    *  *    *
>    *  *    *  *    *  *
>     **      **      **
> And the coding that i have done is as follow.
>
> with Ada.Text_Io, Ada.Float_Text_IO;
> use Ada.Text_Io, Ada.Float_Text_IO;
>
> procedure Graph1 is
>     Y : Integer;
>     Max_Point : Float;
>     Min_Point : Float;
>     Pi : Constant := 3.142;
> begin
>
>     Max_Point := 1.0;
>     for X in 0 .. 360 loop
>        for r in 0.0 .. Max_Point loop
>           Y := sin (X * 2 * Pi/360);
>           Put ("*");
>        end loop;
>     end loop;
> end Graph1;
>
> Could someone tell me what are the mistakes in the coding? Error message
> from the compiler is the 'sin' is undefined. what should i do with this?
>
>
> -- 
> Cecilia Chew
> c e c i l i a <AT> g r e e n l i m e . c o m





  parent reply	other threads:[~2004-01-14  5:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-13  8:44 Problem from a Newbie Cecilia Chew
2004-01-13 12:37 ` David C. Hoos
2004-01-13 17:42 ` Jeffrey Carter
2004-01-14  5:49 ` Steve [this message]
2004-01-14 21:08   ` Simon Wright
     [not found] ` <kc8fd1-ul5.ln1@beastie.ix.netcom.com>
2004-01-14 16:42   ` Jean-Pierre Rosen
2004-01-15  8:56     ` Dmitry A. Kazakov
2004-01-14 17:41   ` Jeffrey Carter
2004-01-15  1:03     ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox