Project: Add Guess Feedback

The current version of the game only tells you whether your guess is right or wrong. Your task is to make it more practical by having the game indicate whether your guess is “Too high” or “Too low.”

For example, if the computer chooses seven and you guess three, it should say “Too low.” If you guess nine, it should say “Too high.”

Project: Add Guess Feedback

The current version of the game only tells you whether your guess is right or wrong. Your task is to make it more practical by having the game indicate whether your guess is “Too high” or “Too low.”

For example, if the computer chooses seven and you guess three, it should say “Too low.” If you guess nine, it should say “Too high.”

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main() {
    srand(time(0));
    int secret = rand() % 10 + 1;  // 1 to 10
    int guess;
    
    cout << "Guess a number between 1 and 10: ";
    cin >> guess;
    
    // Make chnages in the while loop
    while (guess != secret) {
        cout << "Wrong! Try again: ";
        cin >> guess;
    }
    
    cout << "You got it! The number was " << secret << "." << endl;
    return 0;
}
Update the number guessing game