Write a C++ program that uses a while loop to guess a persons age, ask the user if the want to try again if no end the loop. Of course if they guess it the loop also ends
use the rand function to make a guess given a certain range. First you make a guess using rand. Say the guess is between 1 and 130. You will then ask the user if the guess you made is higher or lower than their age depending on what they respond, you will then use rand again to make a guess using the previous value you guessed as a higher or lower range and you keep doing this until the computer "guesses" the age
int guess = (rand() % 100) + 9; //guess from range of 0-100
Is a random number between 9 and 109 (9 and 109 not included)
If you want to make a guess between 0 and 100 (really should be 1 and 100), it should be just rand() % 100 (1 and 100 is rand() % 100 + 1
toupper(input);
Should be input = toupper(input);
As a final note, the aim of this is to make your guess as close the age as possible for each iteration of the while loop. If you keep guessing random numbers between 0 and 100, it will take a while before you finally guess the right age - it is possible, but will be very boring for the user interacting with it. A way to make it faster is to ask the user how close your guess is to their age and adjust the range of guesses by what the user enters.