Question
// Note: - I supposed to use while and if loop and same way the pseudocode the instructor gave us. can you show me i
// Note: - I supposed to use while and if loop and same way the pseudocode the instructor gave us. can you show me i add an output file .txt
#include
int main() { const int MAX_NUM = 100, // const for upper limit MIN_NUM = 1; // const for kower limit unsigned seedNum; // var for seed number (warning unsigned) int randNum, // var for rand number guessNum; // var for guessed number
// gen rand number, store rand number seedNum = time(0); // grab a number based on time srand(seedNum); // scramble randNum = rand() % MAX_NUM + 1; // get rand number // Remove : cout randNum cout
// explain the rules // cout, cin and Q&A
//loop for guessing while (guessNum != randNum && guessNum MAX_NUM) //three paths: 1) guess is too low, 2) guess is too high, 3) guessed //if (guessNum randNum) "too high, try again" //else (guessNum == randNum) "Congrats, you got it " // end if
//thanks for playing //end loop
// 1) get it to work perfect // 2) code for output file system("pause"); return 0; }
12. Random Number Guessing Game Write a program that generates a random number between 1 and 100 and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high. Try again. If the user's guess is lower than the random number, the program should display "Too low. Try again. The program should use a loop that repeats until the user correctly guesses the random number. Then the program should display Congratulations. You figured out my numberStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started