- Write A Program Which Reads A Secret Number And Then A Different User Will Try To Guess The Secret Number By Entering R 1 (59.6 KiB) Viewed 32 times
Write a program which reads a secret number and then, a different user will try to guess the secret number by entering r
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Write a program which reads a secret number and then, a different user will try to guess the secret number by entering r
Write a program which reads a secret number and then, a different user will try to guess the secret number by entering random numbers. Your program will: 1. Read an integer positive value that will be considered as the secret number (secret_number). 2. Ask the other user to input an integer positive number (input_number), will compare it to the secret number and performs the following actions: a. If input number is greater than secret_number, then it will output the message: "too large". If input number is less than secret_number, then it will output the message: "too small". If the user did not guess the secret number (too large or too small), then the program will go back to step 2 and performs actions a, b, and c repeatedly as long as the secret number is not guessed (input_number is not equal to secret_number). 3. If the user has guessed the secret number (input_number is equal to secret_number), then it will output the message: "Congrats" input_number "is the magic number." b. c. Output example: "C\Users\samue OneDrive - University Of Houston Teaching Cplusplus Cpp-Programs\NoProjects\HW4.exe Input the secret number (>0):23 What's the secret number: 50 Too largel What's the secret number:10 To small! What's the secret number: 25 Too large! What's the secret number: 20 To small! What's the secret number:24 Too large! What's the secret number: 23 Congrats! 23 is the magic number. Process returned 0 (0x0) execution time: 32.550 s Press any key to continue. X