Preprocessors


  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. View Hint View Answer Discuss in Forum

    NA

    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


  1. Which of the following names for files not accepted?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    All file names are accepted as for the execution to occur. There are no constraints on giving file names for inclusion.



  1. Which of the following file extensions are accepted with #include?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    The preprocessor will include whatever file extension you specify in your #include statement. However, it is not a good practice as another person debugging it will find it difficulty in finding files you have included.


  1. What will be the output of the following C code snippet?
    #include (stdio.h)
    void main()
    {
    printf("Welcome");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    File to be included must be specified either in “” or <>.



  1. If the file name is enclosed in angle brackets, then ___________.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The preprocessor treats it as a system-defined file