The output of the following program is "they are not equal", but I'd expect "they are equal" as the three compared variables (x
,y
, and z
) are equal. Why?
#include <iostream>
int main()
{
int y, x, z;
y = 3;
x = 3;
z = 3;
if (x == y == z)
{
std::cout << "they are equal
";
}
else
{
std::cout << "they are not equal
";
}
}
See Question&Answers more detail:os