Boolean operation and pre-increment in c

Can anyone explain why c is still 15 after doing

int main(void)
{
    int t,a=5,b=10,c=15;
        t= ++a||++c;
        printf("%d  %d  %d",t,a,c);
}

      

+3


source to share


1 answer


Boolean or operator ||

is a short-circuit operator. If the left side evaluates to a true boolean (i.e., not 0), then the right side fails.



Likewise for boolean and operator &&

, if the left side is false (i.e. 0), the right side is not executed.

+12


source







All Articles