Programming Languages
C
Objective
Mar 08, 2013
What will be output of the following c code?
#define call(x,y) x##y
void main()
{
int x=5,y=10,xy=20;
printf("%d",xy+call(x,y));
}
Detailed Explanation
## is concatenation c preprocessor operator. It only concatenates the operands i.e.
a##b=ab
If you will see intermediate file then you will find code has converted into following intermediate code before the start of actual compilation.
Intermediate file:
test.c 1:
test.c 2: void main(){
test.c 3: int x=5,y=10,xy=20;
test.c 4: printf("%d",xy+xy);
test.c 5: }
test.c 6:
It is clear call(x, y) has replaced by xy.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts