Saturday, January 23, 2010

#include< stdio.h >
main()
{
int a=1,b;
b=a++*2*--a;
printf("%d %d",a,b);
}


Output:

1 0

How it works?
refer precedence operator table
pre decrement(--) will decrement value of 'a'. now a=0.
a++ is post increment, so a will be incremented after multiplication. so
b=0*2*0=0
but after this a will incremented and a=1(because of post increment).

0 comments:

Post a Comment