Could you please explain this code segment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following block of code when compiled with gcc (gcc version 4.4.2
20091027 (Red Hat 4.4.2-7) (GCC) ) resulted in the following output.
Could you please explain how the output differs (when assigned to the
variable b and in printf statement) and the way the compiler executes
each segment of the variable?

int main(){
int a = 10;
int b = (++a) + (++a);
printf("%d %d %d %d\n", b, a++, a, ++a);
printf("%d %d %d %d\n", ++a + ++a, a++, a, ++a);
return 0;
}

OUTPUT
24 13 14 14
36 15 18 18

--
W.H.Kalpa Pathum
http://kalpapathum.blogspot.com
http://thiraya.wordpress.com

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux