I have c++ code
int main()
{
int a = 5, b=5;
bool c;
c = a == b;
cout << c << endl;
return 0;
}
Output is 1
anyone please explain me how come output is 1 and why it is not true?
Because that's how std::ostream::operator<< formats bool values by default. It outputs a 1 for true, and a 0 for false. If you want to print the text "true" or "false", you can use the boolalpha io manipulator:
std::cout << std::boolalpha << c;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With