From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d7c081f926f119a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-13 09:42:18 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.gol.com!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Problem from a Newbie References: <4003b00c_2@news.tm.net.my> In-Reply-To: <4003b00c_2@news.tm.net.my> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Tue, 13 Jan 2004 17:42:17 GMT NNTP-Posting-Host: 63.184.8.78 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1074015737 63.184.8.78 (Tue, 13 Jan 2004 09:42:17 PST) NNTP-Posting-Date: Tue, 13 Jan 2004 09:42:17 PST Xref: archiver1.google.com comp.lang.ada:4370 Date: 2004-01-13T17:42:17+00:00 List-Id: Cecilia Chew wrote: > 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; You do not use Ada.Float_Text_IO. > > procedure Graph1 is > Y : Integer; > Max_Point : Float; > Min_Point : Float; > Pi : Constant := 3.142; Pi is defined in Ada.Numerics to 50 decimal places. It's probably better to use Ada.Numerics.Pi than to duplicate it with your own constant. > begin > > Max_Point := 1.0; > for X in 0 .. 360 loop > for r in 0.0 .. Max_Point loop A for loop operates over a discrete subtype (such as [Integer range] 0 .. 360 used for X), so this construct is illegal. > Y := sin (X * 2 * Pi/360); Sin is, as your compiler told you, undefined. You may define your own, or you may use an instanciation of Ada.Numerics.Generic_Elementary_Functions, or you may use Ada.Numerics.Elementary_Functions, which is an instanciation of Generic_Elementary_Functions for type Float. Sin in [Generic_]Elementary_Functions returns a floating point type; Y is type Integer, so the assignment is illegal unless you've defined your own Sin function that returns Integer. > Put ("*"); This is going to produce a single line of *s regardless of the results of your calculations, so why bother performing the calculations at all? > end loop; > end loop; > end Graph1; -- Jeff Carter "Sir Robin the-not-quite-so-brave-as-Sir-Lancelot, who had nearly fought the Dragon of Angnor, who nearly stood up to the vicious Chicken of Bristol, and who had personally wet himself at the Battle of Badon Hill." Monty Python & the Holy Grail 68