07.05.2015 Views

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

Bronze Edition Guide - True BASIC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

60 BRONZE <strong>Edition</strong> <strong>Guide</strong><br />

More About Counters<br />

In the previous chapter, you saw how a variable can count the number of times something<br />

happens in a program run. The counter there was the variable years. The statement<br />

LET years = years + 1<br />

added 1 to the value stored in years each time the loop was run.<br />

You can use variables such as heads and tails in the COINS program to count the number<br />

of times the toss comes up heads or tails. Add the two LET statements to the IF structure<br />

as shown below along with the two new PRINT statements after the FOR-NEXT loop.<br />

! Flip a coin five times.<br />

!<br />

FOR toss = 1 to 5<br />

IF Rnd

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

Saved successfully!

Ooh no, something went wrong!