178 views

What will be the output of this program ?

#define square(x) x*x
main()
{
int z;
z = 25/square(5);
printf("%d",z);
}


Explanation:
the macro call square(5) will substituted by 5*5 so the expression becomes z = 25/5*5 . Since / and * has equal priority the expression will be evaluated as (25/5)*5 i.e. 5*5 = 25
by

woah woah food for thought!!!
So, square(5) would not return the value of the expression, but the expression itself.

And then since / and * have equal priorities, left associativity would come into play. So, 25.

LOVED this question!

1
214 views