Boolean Operators, Example 3
•
int main
•
{
•
int x = 6, y = 8, z = -1, w = 14,
•
bool result = false;
•
result = (x + z != w) && !(x > 6)
•
cout << result << endl;
•
return 0;
•
}
1
x + z != w, x + z is 5 which is not equal to w (14). So the != operator returns true
x > 6 is not true since x is 6 so > returns false
The ! Operator takes the false from > and makes it true
The && requires both sides to be true which they are so the program prints 1