Computing.Net > Forums > Programming > Problem w/ Random num gen in Pascal

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Problem w/ Random num gen in Pascal

Reply to Message Icon

Name: Comp01
Date: May 18, 2004 at 22:00:31 Pacific
OS: Windows 98SE
CPU/Ram: 566Mhz Celeron/64MB
Comment:

Ok, I know that the identifier for a random number is Random or Random(10) - etc, but, it keeps displaying the SAME numbers over and over, I need it to display DIFFERENT numbers, each time, (specifically a number between 0 and 6 or 0 and 7)... Is there a way to fix this?



Sponsored Link
Ads by Google

Response Number 1
Name: wizard-fred
Date: May 19, 2004 at 00:29:42 Pacific
Reply:

You have to seed the random generator. Is there a statement like RANDOMIZE? Check your language reference. I haven't done a Pascal program in nearly 20 years.

Are you throwing a die?


0

Response Number 2
Name: geolew
Date: May 19, 2004 at 07:30:02 Pacific
Reply:

Try This

The Random command will give you a random number from 0 to the number you give it - 1. The Random command generates the same random numbers every time you run a program so the Randomize command is used to make them more random by using the system clock.

program Rand;

var
i: Integer;

begin
Randomize;
i := Random(101);
end.


George


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Assembly Language managing registry in turb...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Problem w/ Random num gen in Pascal

In Pascal keypressed, in ANSI C..?? www.computing.net/answers/programming/in-pascal-keypressed-in-ansi-c/13486.html

Random Number Gen. In C www.computing.net/answers/programming/random-number-gen-in-c/12219.html

Random Number Generator in C www.computing.net/answers/programming/random-number-generator-in-c/9566.html