inequality and == in a if

113 views Asked by At

Hello I want to understand how compiler read this code with inequality at first and after that check value like this example

int a, b, c;
    a = 4; b = 3; c = 5;
    if (a > b == c)
    {
        cout << "Hello";
    }
    else
    {
        cout << "bye";
    }
1

There are 1 answers

0
Ari Fordsham On

As the OP points out, using two operators in a row is ambiguous syntax. Languages resolve this using a table of operator precedence, to decide which operator is evaluated first. The table for C++ is found here.