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));
 }

Choose the correct answer:
A) 40
B) 35
C) 30
D) Compiler error
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
Feedback