Sunday, February 14, 2010

18

#include < stdio.h >
main()
{
int a=1;
void function(int ,int ,int ); //Function Declaration
function(++a,a,a++); //function call
}
void function(int i,int k,int j)
{
printf("%d %d %d",i,k,j);
}


Output


3      2       1


Logic:


a++     post increment
++a     pre increment
( ) associativity(in which direction operation done) is right to left( i.e., <--)
so first it starts from right i.e.,a++ (post increment) so a=1 is passed to j.
and a will be incremented to 2,then a=2 is passed to k.and finally ++a is preincrement so a=3 and it's passed to i.

0 comments:

Post a Comment