The last function is main. This is responsible for coordinating the actions of the program. It will call play game in a loop that repeatedly plays the game until the user decides to quit. Main will need one local variable called again. This will store the text, and will be used to store the value read from the user’s response to the ‘play again’ prompt.
We can make use of our print line procedure to help separate different games. We can also use read string to check if the user wants to run this again.
Flowchart for the Main method
The following pseudocode shows the steps in main.
Pseudocode for Print Line
Have a go at coding this yourself. When this works you should be able to play multiple games of guess the number.