#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
int n, ans, attempt = 0;
srand(time(0));
n = rand() % 100 + 1;
cout << "Guess My number Game\n\n";
do
{
cout << "Enter a ans between 1 and 100 : ";
cin >> ans;
attempt++;
if (ans > n)
cout << "Too high!\n\n";
else if (ans < n)
cout << "Too low!\n\n";
else
cout << "\nCorrect! Guesses: " << attempt << '\n';
} while (ans != n);
return 0;
}
Comments
Leave a comment