12.07.2015 Views

page-1983-101-timex-sinclair-programming-tricks

page-1983-101-timex-sinclair-programming-tricks

page-1983-101-timex-sinclair-programming-tricks

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.

1 Coin TossHere's a handy way to settle arguments. Toss a coin.Only this time, let the computer do the work!Type in the program. Run it. The computer will reportheads or tails after each toss.For a new toss, press any key on your computer'skeyboard.Line 20 clears the screen. A random number is generatedat line30.Lines 60 and 70 accomplish the restart whenyou press any key .Program Listing10 RAND20 CLS30 LET R=RND40 IF R.5 THEN PRINT •TAILS•60 IF INKEY$=•• THEN GOTO 6070 GOTO 202 Traditional Dice RollHere's a simple, brief way to roll and display resultsfor two dice.Lines 100-110 get a random number between 1 and 6and store it in A. Lines 200-210 get another randomnumber from 1 to 6 and store it in B.Lines 300-310 print the contents of A and B alongwith a suitable message. Lines 400-420 cause the computerto await the press of any key on its keyboard. Whena key is pressed, dice are rolled and new resultspresented on the video display.18

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

Saved successfully!

Ooh no, something went wrong!