> guess; tries++; if (guess > num){ cout << "Too High!\n"; }else if (guess < num){ cout << "Too low!\n"; }else{ cout << "CORRECT! # of tries: " << tries << "\n"; } }while(guess != num); cout << "**************************************"; } "> > guess; tries++; if (guess > num){ cout << "Too High!\n"; }else if (guess < num){ cout << "Too low!\n"; }else{ cout << "CORRECT! # of tries: " << tries << "\n"; } }while(guess != num); cout << "**************************************"; } "> > guess; tries++; if (guess > num){ cout << "Too High!\n"; }else if (guess < num){ cout << "Too low!\n"; }else{ cout << "CORRECT! # of tries: " << tries << "\n"; } }while(guess != num); cout << "**************************************"; } ">
#include <iostream>  
#include <ctime>
using namespace std;  
int main() {
   int num; 
   int guess; 
   int tries = 0; 
   srand(time(NULL)); 
   num = (rand() % 100) +1 ;
   cout << "***** NUMBER GUESSING GAME *****\\n"; 

   do{
    cout << "Enter a guess between (1 - 100): "; 
    cin >> guess; 
    tries++; 
    
    if (guess > num){
        cout << "Too High!\\n";
    }else if (guess < num){
        cout << "Too low!\\n";
    }else{
        cout << "CORRECT! # of tries: " << tries << "\\n"; 
    }

   }while(guess != num);
cout << "**************************************";
}

First, I got into some trouble getting weird numbers from the Tries. However, I asked ChatGPT to see and check my code. The AI gave me this problem:

Screenshot 2023-04-17 at 8.42.41 AM.png