#include<stdio.h>
int main(void)
{
int a = 1;
int b = 0;
int c = a || --b;
int d = a-- && --b;
printf(“a=%d, b=%d, c=%d, d=%d\n”,a,b,c,d);
return 0;
}
#include<stdio.h>
int main(void)
{
int a = 1;
int b = 0;
int c = a || --b;
int d = a-- && --b;
printf(“a=%d, b=%d, c=%d, d=%d\n”,a,b,c,d);
return 0;
}
so a=0,b=-1,c=1,d=1.
okay so c=a||–b, in this since it an or operator so we know thatif any of the value is true then it will be true, since the value of a is now 1 which means true so it will not go into --b and it will stop after operating ‘a’ only, so ‘c’ becomes 1.
Now for d=a-- whose value is 1 for now and now we get into --b whose value is -1 now since we have pre decremented it, as we know that for all non zero value of && the value is 1, therefore d=1.
now a=0, since we have post decremented in d beforehand.
|
Hope u got it, sorry if my explanation ain’t that good.