Preprocessors


  1. The below two lines are equivalent to ________.
    #define C_IO_HEADER <stdio.h>
    #include C_IO_HEADER











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Since C_IO_HEADER is defined to be <stdio.h>, the second line becomes #include<stdio.h>, since C_IO_HEADER is replaced with <stdio.h>


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Compilation Error

    main.c:2:14: fatal error: printf: No such file or directory
    #include "printf"
    ^~~~~~~~
    compilation terminated.



  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. 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. 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