|
Qbasic Tutorial for beginners and children (Under Construction) |
Generating random numbersThe computer does not have the capacity to choose one number randomly from a list of numbers. This is a prerogative of the human being. However this can be simulated using three keywords.
The RND functionQbasic uses the RND function to draw upon a pseudo-random sequence of numbers that are stored internally. These numbers are decimals which range from 0 to 1. So a statement like
If you want to get random numbers between 0 and 10, proceed as follows:
To get integers use the INT function. Remember, the INT function returns the highest number which is less that the numeric expression.
The RANDOMIZE statementThe TIMER function
The only thing which continuously changes in the computer is its internal clock The TIMER function return the number of seconds elapsed since midnight. |
|
|