Shortcircuiting of AND in case of increment / decrement operator
In the code below: #include <stdio.h> int main() { int a = 1; int b = 1; int c = a || --b; int d = a-- && --b; printf("a = %d, b = %d, c = %d, d = %d", a, b, c, d); return 0; } i was expecting the output to be: a=0,b=1,c=1,d=0 because due to short circuiting in the line below, ie a-- returns 0 so the other part wont get executed right? int d = a-- && --b; The output is: a = 0, b = 0, c = 1, d = 0 can anyone please explain? int c = a || --b; In this line, the C standard requires the C implementation to evaluate a first and, if it is not zero, not to evaluate --b . Although -- has higher