Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!samsung!crackers!m2c!wpi.WPI.EDU!kamal From: kamal@wpi.WPI.EDU (Kamal Z Zamli) Newsgroups: comp.lang.pascal Subject: Re: procedure rnd(help); Message-ID: <1991Feb20.143116.25025@wpi.WPI.EDU> Date: 20 Feb 91 14:31:16 GMT References: <1991Feb19.232457.408@miavx2.ham.muohio.edu> Organization: Worcester Polytechnic Institute Lines: 62 In article <1991Feb19.232457.408@miavx2.ham.muohio.edu> brpleshek@miavx2.ham.muohio.edu writes: >i'm working on translating on of my programs from Basic to Pascal, but i'm >having trouble creating a random number generation routine. Any of them out >there? Any help would be appreciated. > >thanx Try the following codes: const Max = 100; type List = array [1..Max] integer; var Data:List; procedure RandomNumber (var Data:List); var i:integer; begin Randomize; (* initialize random number generator *) for i:=1 to Max do begin List[i]:=Rnd (100); (* generate a positive only random number between 1 to 100 *) end; end; (* RandomNumber *) begin RandomNumber(Data); end. Sometimes you might want to vary your random number generator such that it will produce a negative number as part of the number. in order to do that type the follwin code: procedure RandomNumber (Vat Data:List); var i:integer; Temp:integer; begin Randomize; for i:=1 to Max do begin Temp:=Rnd(100); List[i]:=Temp - 50; (* get some negative number too *) end; end;