Sunday, February 7, 2010

10

#include < iostream.h >
main()
{
int a=1,b=2;
a=a,b;
b=(a,b);
cout < < a < < b;
}

OUTPUT

1    2
How?

as said in last post 'a=a,b;' is equal to
a=a;
b;
so a=1.
in next line i.e 'b=(a,b)':
in this expression we use brackets(brackets has 'right to left associativiy' i.e
operation will be in this direction <-- )
so b=b will be assigned.i.e.,
b=b;
a;
so b=2.

0 comments:

Post a Comment