( MindTap - Cenage )Example 5-6 implements theNumber Guessing Game program. If the guessed number is not correct, the program outputs a message indicating whether the guess is low or high.
Modify the program as follows: Suppose that the variables num and guess are as declared inExample 5-6 and diff is an int variable. Let diff = the absolute value of (num - guess).
If diff is0, then guess is correct and the program outputs a message indicating that the user guessed the correct number.
Suppose diff is not0. Then the program outputs the message as follows:
give the user no more than five tries to guess the number.
(To find the absolute value of num - guess, use the expression abs(num - guess). The function abs is from the header file cstdlib.)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here