| Chapter 3- Data Types and Operators | Boolean Expressions Page 2 3 4 |
| The If Statement Page 2 3 4 5 6 7 8 9 | |
| Arithmetic Operations Page 2 3 4 5 6 | Boolean Operators and Nested If Statements Page 2 3 4 5 6 7 |
| Events and Sequential Processing Page 2 3 4 5 | More Examples Page 2 3 4 5 6 7 8 9 10 11 12 |
| Datatypes and Conversions Page 2 3 4 5 6 7 | Using Check Box and Option Controls Page 2 3 4 5 6 7 8 9 10 |
| Variable Declarations - Local and Global Page 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Exercises Page 2 3 4 5 6 7 8 |
| Chapter 4- Selection Statements | Review Questions |
| Introduction | |
4-6: More on Nested If Statements
Exercise 4-4: Improving the Guessing Game (continued)
Realising that we need a variable to keep track of the number of guesses remaining, lets call it guessesRemaining, and also realising that it should be declared as Integer, the first question we should resolve is where to declare this variable. The options are either global (outside of any event subprogram) or local (inside an event subprogram, probably the Check It click event).
The second question to consider is where - in which event(s) - this variable, guessesRemaining, should be initialised? It should be clear that the initial value, i.e. each time a new game is started, should be 7. The events we have implemented in the program are the following:
(Hint: the variable must be initialised in two events.)