Bronze Edition Guide - True BASIC
Bronze Edition Guide - True BASIC
Bronze Edition Guide - True BASIC
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
78 BRONZE <strong>Edition</strong> <strong>Guide</strong><br />
PRINT “You got”; 100 * right/num_quest; “% right.”<br />
DATA 5<br />
DATA What is the capital of Austria, Vienna<br />
DATA What year did Franklin Pierce take office, 1853<br />
DATA “What is the capital of Manitoba, Canada”, Winnipeg<br />
DATA “How many years, on average, does a baboon live”, 20<br />
DATA How about a gray squirrel, 5<br />
END<br />
The first executable statement after the initial comment lines is a READ statement. This<br />
“reads” the first item in the first DATA statement and assigns that value to the variable<br />
num_quest. The value of num_quest determines how many times the program goes through<br />
the FOR-NEXT loop.<br />
The second READ statement is inside the FOR-NEXT loop. It gets the next two values from<br />
the list of DATA statements and assigns them to the two variables in the READ statement.<br />
Question$ takes the value “What is the capital of Austria” and answer$ gets the value<br />
“Vienna”. The next time through the loop, question$ and answer$ take the next two values<br />
in the DATA statements, and so on.<br />
Run the program to see how it works. You can give any answers you want; the dialog below<br />
is just a sample.<br />
What is the capital of Austria? Salzburg<br />
No, the correct answer is Vienna.<br />
What year did Franklin Pierce take office? 1844<br />
No, the correct answer is 1853.<br />
What is the capital of Manitoba, Canada? Winnipeg<br />
Correct.<br />
How many years, on average, does a baboon live? 20<br />
Correct.<br />
How about a gray squirrel? 15<br />
No, the correct answer is 5.<br />
You got 40 % right.<br />
———————————————————————————————————————<br />
x DATA statements may be placed anywhere in your program.<br />
———————————————————————————————————————<br />
You saw that the location of the DATA statements didn’t matter when you moved them in<br />
the SMOKY program in the last chapter. Often they go at the very end of a program; some-