Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// Note: - I supposed to use while and if loop and same way the pseudocode the instructor gave us. can you show me i

image text in transcribed

// 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 #include #include using namespace std;

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 number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions