PURPOSEYour task is to write a C++ programGuessNumber which playsan integer gues
ID: 3608226 • Letter: P
Question
PURPOSEYour task is to write a C++ programGuessNumber which playsan integer guessing game with the user.
REQUIREMENTS
1.
Your program should generate a random integer, 10 thru 20 inclusive, upon each run. Asimple wayto accomplish this is demonstrated inthe codesnippet shownbelow…
#include <ctime>
using std::time;
....
int randomdigit;
randomdigit = 10 + (time(0) % 10);
....
2.
Your program should prompt the user for an integer in the rangeof10 thru20.
a.
NOTE: your program should catch unreasonable userinputs (integers outside of the
range of desired values) and prompt for re.input.
3.
Your program should continue to prompt the userfor another integer inputuntil they guess correctly.
a.
If the guess is too low, display “Too low, try again.”
b.
If the guess is too high, display “Too high, try again.”
c.
If the guess is correct, display “You guessed correctly!” thenterminate.
Explanation / Answer
#include #include using namespace std; int main() { int randomdigit, userInput; bool correct; randomdigit = 10 + (time(0) % 10); correct = false; while (!correct) { cout >userInput; if (userInput < 10 ||userInput > 20) { cout randomdigit) coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.