#import <stdio.h>
int main()
{
int a,d,b,c;
a = 10;
c = 10;
d = --c + --c+1;
b = --a +1+ --a ;
printf("b= %d, d = %d" , b,d);
return 0;
}
b= 18, d = 17
Why d&b are not equal? can you please explain why d=17?
#import <stdio.h>
int main()
{
int a,d,b,c;
a = 10;
c = 10;
d = --c + --c+1;
b = --a +1+ --a ;
printf("b= %d, d = %d" , b,d);
return 0;
}
b= 18, d = 17
Why d&b are not equal? can you please explain why d=17?
Oh right, it's because it's undefined when the value of a
and c
will decrement.
d = --c + --c+1;
If c
is decremented twice and then d
is calculated, then it gives
d = 8 + 8 + 1 = 17
But if c
is decremented as we proceed from left to right, then it gives
d = 9 + 8 + 1 = 18