C operator -- gives two different results -
#import <stdio.h> int main() { int a,d,b,c; = 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 not equal? can please explain why d=17?
oh right, it's because it's undefined when value of a , c decrement.
d = --c + --c+1; if c decremented twice , d calculated, gives
d = 8 + 8 + 1 = 17 but if c decremented proceed left right, gives
d = 9 + 8 + 1 = 18
Comments
Post a Comment