That cured the problem of not having results larger than 1, but we still
have the decimal part of the result to deal with. Now, another function
can be called upon.
The INTeger function converts real numbers into integer values.
Once more, replace line 20 with the following and run the program to
see the effect of the change:
That took care of a lot, getting us closer to our original goal of
generating random numbers between 1 and 6. If you examine closely
what we generated this last time, you'll find that the results range from
o to 5, only.
As a last step, add a one to the statement, as follows:
2" PRINT INT(6*RND(1»+l,
Now, we have achieved the desired results.
In general, you fan place a number, variable, or any BASIC expres-
sion within the parentheses of the INTfunction. Depending on the range
desired, you just multiply the upper limit by the RND function. For
example, to generate random numbers between 1 and 25, you could
type:
2" PRINT INT(2S*RND(1»+ 1
The general formula for generatind a set of random numbers in a
certain range is:
NUMBER=INT(LOWER LIMIT+(UPPER-LOWER+ 1)*RND(1»
GUESSING GAME
Since we've gone to some lengths to understand random numbers,
why not put this information to use? The following game not only iIIus-
50