Why is my Boolean operation in VS Code not given expected result?

41 views Asked by At

I tried to solve C++ expression quizzes on TLX. There is a problem about Boolean operation which I got confused. The question is like "If a = true, b = false, c = true, and d = true, then the value of a && !d || !c || a && b is ..." and the answer is false.

I had tried to write a code in VS Code to see the output, I got 1 as the result instead of 0. Indeed, the answer should be false when we follow the operator precedence. But why in VS Code it seems like the execution didn't work as it should?

Here is the code I wrote in VS Code

#include <iostream>
using namespace std;

int main() {
    bool a, b, c, d;
    a = true;
    b = false;
    c = true;
    d = true;
    
    cout << a && !d || !c || a && b;
}
0

There are 0 answers