The RND function returns a random positive integer.
Format
RND(expr) |
Parameter(s)
expr |
An expression evaluating to an integer. The random number generated is between 0 and expr-1. |
Description
The RND function generates a random integer. If expr evaluates to a negative value, the RND function returns 0.
If expr evaluates to a noninteger value, the decimal part to expr is truncated.
Example
In this application, a user is asked to guess a number from 1 to 10:
PRINT "GUESS A NUMBER FROM 1 TO 10" INPUT GUESS ANSWER = RND(10) + 1 IF GUESS = ANSWER THEN PRINT "YOU WIN" END ELSE PRINT "NO, IT WAS" : ANSWER END |
See Also