0
how d=0 ?
#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; } // Here the output is a = 0, b = 0, c = 1, d = 0
2 Answers
+ 8
Arun as after decrement the value of a and b is 0 so by doing AND operation it will too return 0 as AND will return true when both operand is true or 1 else every other conditions will return 0 like
a b output
0 0 0
0 1 0
1 0 0
1 1 1
so d return 0 as both the values of a and b is 0