From my understanding what is supposed to happen is (for example, entering 3 and 4) I get a 1 for 'equal' indicating it was not true and a 0 for 'notequal' indicating it was true. Instead, for example, when entering the numbers 3 and 4, I get a 0 for equal and a 1 for notequal, and it is very frustrating. I'm not sure what is wrong, and any help would be greatly appreciated. Thank you.
You need to use an if statement there. you say if a equals to b boolean equal is true else it is false and if a not equals b boolean notequal is true else it is false. You dont check values of your booleans.
int main ()
{
cout << "Please enter two numbers" << endl;
int a , b;
cin >>a;
cin >> b;
bool isEqual = (a==b);
if( isEqual )
{
cout<< "They are equal";
}
else
cout>>"They are not equal";
return 0;
}
Actually, it's doing the right thing, it's your expectations that are opposite.
a "1" in this case means "true" and 0 means "false" I've read of but never come across (I'm sure they exist though) any scheme that uses "0" for true and "1" for false.
senhor: Thanks for the suggestion on an if statement, but I am yet to reach the if statement part of the book yet so I was unable to use it here
tipaye: I really appreciate the help, I genuinely though 0 was seen as true because you usually return 0 at the main function, and I thought that had something to do with it being true. Anyway, I've realized my mistake. I knew the compiler couldn't seemingly work but give me strange results in that way.
jlb: Thanks for the new 'boolalpha' and 'noboolalpha' to use, they definitely make it easier to understand and would have told me right away if I was correct.
Thanks to everyone for the help.