0

why my randomize commond doesn`t work in my pascal program? i used many loops in my program which i put the randomize after the first begin of the program.

Is there some one can tell me how to place the randomize command in a complicated pascal program!

:rolleyes:

THX...........

4
Contributors
4
Replies
7
Views
11 Years
Discussion Span
Last Post by Lord Soth
0

Easy, put this right after the first begin and then use x:=random(y)+1 to get a random integer.

program blah;
var a,b:integer;
begin 
for a:= 1 to 1000000 do inc(b);
a:=random(10)+1; {this makes "a" a random number from 1 to 10}
writeln(a);
end.
0

Hi,

Randomize just seeds the Random Number Generator (RNG) of Pascal/Delphi with the current time. You better put it as the first line of the code or before the first call to random() function. It doesn't have to be called many times just once is enough. If you don't use it your random() function would generate the same sequence every time you run your program.

Loren Soth

0

Hi, can someone please tell me what writeln means? I have done a random command and I haven't used that, and what are you making angus1910?

0

Hi, can someone please tell me what writeln means? I have done a random command and I haven't used that, and what are you making angus1910?

Writeln -> Write Line (to the console which is screen)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.