A copy of Smac89's code. Interesting.
To the eye it seems faultless, however if it's giving you problems you could do some serious inception if statements(I think, more conventionally named, 'Nested'?).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
//.......
cin >> answer;
if ((random_number == random_number2)
{
if(answer == "yes")
{
cout << "You are correct!\n";
}
else
{
cout << "You are incorrect!\n";
}
}
// I'm sure you get the idea.
|
Also if your using Visual C++ Express, as I guess I'd say your using windows. so change,
system("clear");
to
system("cls");
EDIT: Had to change from 'else if' to 'else'
EDIT2:
I'd say it is easier to compare an integer than a string, instead of the user typing 'yes' . So try using 0 as yes and 1 as no.
Or ( a more drastic approach ) would be designing your own comparison algorithm. Easiest way to compare 2 entities is using XOR, the ^ operator.
if(random_number ^ random_number2 = 0)
{
cout << "Numbers are the same!\n";
}
else
{
cout << "Numbers are not equal!\n";
}