I don't understand why this program will not compile please help.
This is what the program supposed to do.
After the correct number is guessed or all five guesses are used and the correct number is not guessed, the user will see a message that shows the secret number and tells how many guesses were used.
Ask the user if he wants to play again. If yes, repeat steps 2 through 5. If not, thank the user for playing and end the program.
#include <iostream>
using namespace std;
int main()
{
system("color 4");
restart:
int number, ans;
number = rand() % 100 + 1;
int guess, tries=5;
do {
cout << "Can you guess my secret number? You have 5 tries, (1-100). "<< endl;
cout << "Enter guess number: ";
cin >> guess;
if (guess < number)
cout << "Too low, try again!" << endl;
else if (guess > number)
cout << "Too high, try again!" << endl;
else if (guess == 42);
cout << "Your guess is right!" << endl;
}
}
if (tries > 5)
{
cout << "You haven't guess my secret number. The secret number is 42. Would you like to start again?";
cout << "Press 'Y' or 'y', " << endl;
cin >> ans;
else if (ans != 'Y' || ans != 'y')
{
goto restart;
}
}
system("PAUSE");
return(0);
}