Home » C Programming » Preprocessors » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    #define function(p, q) p ## q
    int main()
    {
    printf("%s\n", function(a, b));
    }
    1. p q
    2. a b
    3. Undefined behaviour
    4. Compilation Error
    5. None of these
Correct Option: D

Compilation Error

main.c: In function ‘main’:
main.c:5:33: error: ‘ab’ undeclared (first use in this function)
printf("%s\n", function(a, b));
^
main.c:2:28: note: in definition of macro ‘function’
#define function(p, q) p ## q
^
main.c:5:33: note: each undeclared identifier is reported only once for each function it appears in
printf("%s\n", function(a, b));
^
main.c:2:28: note: in definition of macro ‘function’
#define function(p, q) p ## q



Your comments will be displayed only after manual approval.