Guess a number! #WSQ06

This program generates one random number between 1 and 100 and you have to guess it. It will tell you if you have to pick a lower number or a highier number until you guess it the program will finish. You win if you try less than five times, if not, you lose. To write this program I had to include two new libraries besides iostream, to use the function srand, which helps to generate the random numbers: they are cstdlib and time.h.

Here is the code:

 

Here is the program executed:

CC BY 4.0 Guess a number! #WSQ06 by Alan Valdovinos is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.