17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

GW-BASIC <strong>User's</strong> Guide<br />

RND Function<br />

Purpose:<br />

To return a random number between 0 and 1.<br />

Syntax:<br />

RND[(x)]<br />

Comments:<br />

The same sequence of random numbers is generated each time the program is run unless the<br />

random number generator is reseeded (see RANDOMIZE statement). If x is equal to zero, then<br />

the last number is repeated.<br />

If x is greater than 0, or if x is omitted, the next random number in the sequence is generated.<br />

To get a random number within the range of zero through n, use the following formula:<br />

INT(RND*(n+1))<br />

The random number generator may be seeded by using a negative value for x.<br />

Examples:<br />

10 FOR I=1 TO 5<br />

20 PRINT INT(RND*101);<br />

30 NEXT<br />

RUN<br />

53 30 31 51 5<br />

Generates five pseudo-random numbers within the range of 0-100.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/RND.html28/03/2004 21.29.44

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!