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.6 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5d7204ff396525aa,start X-Google-Attributes: gid103376,public From: Eric Sabo Subject: Please help link list! Date: 1997/12/04 Message-ID: <01bd0074$856c1020$8d484893@default>#1/1 X-Deja-AN: 295078069 Sender: Ada programming language Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 X-MSMail-Priority: Normal Newsgroups: comp.lang.ada Date: 1997-12-04T00:00:00+00:00 List-Id: This is a multi-part message in MIME format. ------=_NextPart_000_1BB5_01BD004A.9C960820 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable What am I doing wrong with this program? with gnat.io; use gnat.io; procedure testing is type link_integer; type pointer is access link_integer; type link_integer is record number : integer; next : pointer; end record; first, last, p : pointer; temp : integer; begin =20 put("Project Number two"); p :=3D new link_integer; first :=3D p; last :=3D p; -- Entering the link list put_line("Please enter a number: "); get(temp); while temp /=3D -99 loop p.number :=3D temp; p :=3D new link_integer; last.next :=3D p; first.number :=3D temp; last :=3D p; put_line("Please enter a number: "); get(temp); first.number :=3D temp; first.next :=3D p; end loop; =20 -- printing outing the link list temp :=3D first.number; while temp /=3D last.number loop put("The number is "); put(temp); =20 temp :=3D p.number; end loop; end testing; Thanks, Eric Sabo sabo@hhs.net ------=_NextPart_000_1BB5_01BD004A.9C960820 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
What am I doing wrong with this=20 program?
with gnat.io; = use=20 gnat.io;
procedure testing is
type link_integer;
type pointer = is access=20 link_integer;
type link_integer is
  =20 record
      number :=20 integer;
      next : = pointer;
   end=20 record;
 
first, last, p : pointer;
temp :=20 integer;
begin
     =
    =20 put("Project Number two");
     p :=3D = new=20 link_integer;
     first :=3D=20 p;
     last :=3D p;
-- Entering the link=20 list
     put_line("Please enter a number:=20 ");
     = get(temp);
    =20 while temp /=3D -99 = loop
        =20 p.number :=3D temp;
         = p :=3D new=20 link_integer;
         = last.next :=3D=20 p;
         first.number :=3D = temp;
         last :=3D=20 p;
         = put_line("Please=20 enter a number: = ");
        =20 get(temp);
         = first.number :=3D=20 temp;
         first.next = :=3D=20 p;
     end loop;      =
--=20 printing outing the link list
   temp :=3D=20 first.number;
   while temp /=3D last.number=20 loop
      put("The number is=20 ");
     =20 put(temp);      =
      temp=20 :=3D p.number;
   end loop;
 
end testing;
 
Thanks,
Eric Sabo
sabo@hhs.net
------=_NextPart_000_1BB5_01BD004A.9C960820-- 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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5d7204ff396525aa X-Google-Attributes: gid103376,public From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) Subject: Re: Please help link list! Date: 1997/12/05 Message-ID: <881301956.91snx@jvdsys.nextjk.stuyts.nl>#1/1 X-Deja-AN: 295376253 References: <01bd0074$856c1020$8d484893@default> Distribution: world Organization: *JerryWare HQ*, Leiden, Holland Newsgroups: comp.lang.ada Date: 1997-12-05T00:00:00+00:00 List-Id: In article <01bd0074$856c1020$8d484893@default> sabo@HHS.NET writes: >What am I doing wrong with this program? Three remarks up-front: 1) Disable HTML in your mailer, as this is very hard to read using an ascii based mailer 2) Use one of the standard Ada styles for writing code, this makes it much more readable for others 3) GNAT.IO is a gnat specific package, use the language standard IO packages Technically speaking you are doing nothing wrong with the program, when compiled it does exactly what you instructed it to do. Probably you mean it is not doing what you intended it to do. As this looks like an assigment, best thing to do is ask you instructor for help. If your assignment is to program a linked list, this is coming quite close, but the program contains several logic errors. A old-fashioned technique I find very useful for finding errors like this is to print out the program, take a blank sheet of paper, and execute it yourself. That is, write down the variables starting values, enter a number, follow the program, writing down the new values of the variables as they are updated. After a few iterations, check if the values the variables are assigned to are what you expected them to be. -- -- Jerry van Dijk | Leiden, Holland -- Consultant | Team Ada -- Ordina Finance | jdijk@acm.org 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,5d7204ff396525aa X-Google-Attributes: gid103376,public From: "bklungle" Subject: Re: Please help link list! Date: 1997/12/05 Message-ID: <668kd0$mmc@dfw-ixnews3.ix.netcom.com> X-Deja-AN: 295433040 References: <01bd0074$856c1020$8d484893@default> X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Organization: B & D Associates X-NETCOM-Date: Fri Dec 05 4:18:08 AM CST 1997 Newsgroups: comp.lang.ada Date: 1997-12-05T04:18:08-06:00 List-Id: This is a multi-part message in MIME format. ------=_NextPart_000_0026_01BD0124.8F17E440 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am afraid I have to agree with Jerry Van Dijk. I had your code = rewritten and working and ready to send it to you, along with the pseudo = code (structured english statements) for it. I read Jerry's comment and = decided it wasn't fair to do your work for you. As a hint, you started = out ok, then seem to have forgotten what a link list is, or you are = trying to design on the terminal using code. Unless you are an expert in = a language, you shouldn't do this. Draw a detailed flowchart, or do a = Nassi-Schneiderman, or write a pseudo-code detailed description of the = steps, or do it in spanish, or, ...; remember, your instructor is your = best friend in this endeaver. Incidentally, every book I have ever seen = on Ada, Pascal, C, etc has code in it to do almost exactly what you are = doing.=20 cheers...bob Eric Sabo wrote in message <01bd0074$856c1020$8d484893@default>... What am I doing wrong with this program? with gnat.io; use gnat.io; procedure testing is type link_integer; type pointer is access link_integer; type link_integer is record number : integer; next : pointer; end record;=20 first, last, p : pointer; temp : integer; begin =20 put("Project Number two"); p :=3D new link_integer; first :=3D p; last :=3D p; -- Entering the link list put_line("Please enter a number: "); get(temp); while temp /=3D -99 loop p.number :=3D temp; p :=3D new link_integer; last.next :=3D p; first.number :=3D temp; last :=3D p; put_line("Please enter a number: "); get(temp); first.number :=3D temp; first.next :=3D p; end loop; =20 -- printing outing the link list temp :=3D first.number; while temp /=3D last.number loop put("The number is "); put(temp); =20 temp :=3D p.number; end loop;=20 end testing; =20 Thanks, Eric Sabo sabo@hhs.net ------=_NextPart_000_0026_01BD0124.8F17E440 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I  am afraid I have to agree = with Jerry Van=20 Dijk. I had your code rewritten and working and ready to send it to you, = along=20 with the pseudo code (structured english statements) for it. I read = Jerry's=20 comment and decided it wasn't fair to do your work for you. As a hint, = you=20 started out ok, then seem to have forgotten what a link list is, or you = are=20 trying to design on the terminal using code. Unless you are an expert in = a=20 language, you shouldn't do this. Draw a detailed flowchart, or do a=20 Nassi-Schneiderman, or write a pseudo-code detailed description of the = steps, or=20 do it in spanish, or, ...; remember, your instructor is your best friend = in this=20 endeaver. Incidentally, every book I have ever seen on Ada, Pascal, C, = etc has=20 code in it to do almost exactly what you are doing.
 
cheers...bob
Eric Sabo wrote in message=20 <01bd0074$856c1020$8d484893@default>...
What am I doing wrong with this=20 program?
with = gnat.io; use=20 gnat.io;
procedure testing is
type link_integer;
type = pointer is=20 access link_integer;
type link_integer is
  =20 record
      number :=20 integer;
      next : = pointer;
  =20 end record;
 
first, last, p : pointer;
temp :=20 integer;
begin
     =
    =20 put("Project Number two");
     p = :=3D new=20 link_integer;
     first :=3D=20 p;
     last :=3D p;
-- Entering the link=20 list
     put_line("Please enter a = number:=20 ");
     = get(temp);
    =20 while temp /=3D -99 = loop
        =20 p.number :=3D = temp;
         p :=3D=20 new = link_integer;
        =20 last.next :=3D = p;
        =20 first.number :=3D = temp;
        =20 last :=3D p;
        =20 put_line("Please enter a number:=20 ");
        =20 get(temp);
         = first.number=20 :=3D temp;
         = first.next :=3D=20 p;
     end = loop;     =20
-- printing outing the link list
   temp :=3D=20 first.number;
   while temp /=3D last.number=20 loop
      put("The number is=20 ");
     =20 put(temp);      =
     =20 temp :=3D p.number;
   end loop;
 
end testing;
 
Thanks,
Eric Sabo
sabo@hhs.net
------=_NextPart_000_0026_01BD0124.8F17E440--