The game works for the first two attempts then it just stops working does my code has some semantic error?The game randomly chooses a number from one to one hundred and tells you if your guess is too high or too low why might it work for two attempts then stop working?
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int main()
{
int your_guess;
int lowest = 1;
int highest = 100;
int random_number = rand() % 100 +1;
cout << "Guess a number between 1-100: " << "\n";
cin >> your_guess;
while (your_guess != random_number);
if (your_guess > random_number)
{
cout << "Your guess is too high\n";
}
else if (your_guess < random_number)
{
cout << "Your guess is too low\n";
}
else
{
cout << "Correct" << your_guess << "Is the correct number\n";
return 0;
}
}
Aucun commentaire:
Enregistrer un commentaire