Preprocessors


  1. Comment on the output of the following C code.
    #include <stdio.h>
    #include "test.h"
    #include "test.h"
    int main()
    {
    //statements...
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

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


  1. How is search done in #include and #include ”somelibrary.h” normally or conventionally?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    When former is used, predefined directory is searched and when latter is used, current directory is searched and then predefined directories are searched



  1. Can function definition be present in header files?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Yes


  1. How is search done in #include and #include “somelibrary.h” according to C standard?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    When former is used, search is done in implementation defined manner and when latter is used, current directory is searched.



  1. What will be the output of the following C code?
    #include <stdio.h>
    #define function(p, q) p ## q
    void fun();
    int main()
    {
    fun();
    }
    void fun()
    {
    printf("%d \n", function(10, 15));
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    1015