Question
Can someone help me find mistakes I really appreciate it! Project: Guess a number within a given range. Find and fix the errors (syntax and/or
Can someone help me find mistakes I really appreciate it!
Project: Guess a number within a given range.
Find and fix the errors (syntax and/or logical) Run the program twice and save each output as a comment at the end of the source file.
The program generates a random number within the range MIN to MAX (inclusive) and asks the user to guess it in one or two tries.
*/ #include
using namespace std;
const int MIN = 1; const int MAX = 10; int main() { int random_num; int num;
srand(time(0)); random_num = rand() % 9 + 1; cout << "Enter a number within the range 1 to 10: "; cin >> num; // first try if( num = random_num ) cout < < "Congratulations! You did it! "; else if( num < randomNum ) cout << Your guess is low!; esle cout << "Your guess is high!" cout << " Try again! "; count >> Enter a number within the range 1 to 10: ; cin >> num; // second try iff( num = random_num ) cout << "Congratulations! You did it! " else; cout << ''Sorry, the number was %d ", random_num; } return O; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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