The program generates random numbers that are always one less
than the number by which it is multiplied. The first line 10 generates
the numbers 0, 1, and 2. To generate random numbers 0, 1, 2, and 3,
the program would be written this way:
10 PRINT INT ( R N D ( 0 ) * 4 )
RUN
To generate only the numbers 1, 2, and 3, the program should look
like this:
10 PRINT INT ( R N D ( 0 ) * 3 ) + 1
RUN
To generate three numbers starting at 20, write the program this way:
10 PRINT INT ( R N D ( 0 ) * 3 ) + 2 0
RUN
Random Number Game
Random-number programs are very flexible. You can even use them to
play games with your computer. Type the following program.
Remember that to get the bent arrow in line 5, press , hold down
or , and press
NEW
1 REM *** NUMBER.GAM ***
5 PRINT " "
10 SECRETNUM=INT(RND(0)*3)+1
20 PRINT: PRINT "I AM THINKING OF A N U M B E R , EITHER 1, 2,
OR 3 . TRY TO GUESS IT . "
30 INPUT GUESS
40 IF G U E S S = S E C R E T N U M THEN PRINT "YOU WON. "
50 IF GUESS<>SECRETNUM THEN PRINT "YOU LOST. "
60 GOTO 10
Line 10 assigns the random number to the numeric variable called
SECRETNUM. Line 30 lets the user type in a guess and assigns this
number to the numeric variable called GUESS. (Remember that
numeric variables do not need to be dimensioned or tagged at the end
the way that string variables do.) Line 40 compares the guess to the
secret number. If they equal each other, the computer prints "YOU
WON." Line 50 also compares the guess to the secret number. If they
are not equal (the symbols < > mean not equal to), the computer prints
"YOU LOST." Line 60 makes a loop so that you can play the game
again. (The next chapter explains IF-THEN statements in more detail.)
52
Summary of Contents for 65XE
Page 1: ...ATARI 65XE PERSONAL COMPUTER OWNER S MANUAL TM...
Page 3: ...ATARI 65XE PERSONAL COMPUTER TM...
Page 6: ...Part 1 GettingStarted 1...
Page 9: ...4...
Page 23: ...18...
Page 25: ...20...
Page 32: ...Part 2 Programming withATARI BASIC 27...
Page 33: ...28...
Page 59: ...54...
Page 69: ...64...
Page 82: ...Part3 Appendices 77...
Page 83: ...78...
Page 97: ...92...
Page 105: ...100...
Page 125: ...120...
Page 126: ...121 Index...
Page 127: ...122...
Page 134: ...ATARI 1987 Atari Corp All Rights Reserved Printed in Taiwan C072018 001 REV B K l 2 1987...
Page 135: ......