Preprocessors


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    #define const int
    const min = 41;
    printf("%d", min);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    41


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    #define min 85
    printf("%d", min);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    85



  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    #define min 56;
    printf("%d", min);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    Compilation Error

    main.c: In function ‘main’:
    main.c:4:23: error: expected ‘)’ before ‘;’ token
    #define min 56;
    ^
    main.c:5:22: note: in expansion of macro ‘min’
    printf("%d", min);


  1. What is the advantage of #define over const?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Data type is flexible



  1. What will be the output of the following C code?
    #include <stdio.h>
    int calc(int, int);
    #define calc(p, q) p / q + p
    int main()
    {
    int a = -17, b = 12;
    printf("%d ",calc(a + b, 12));
    #undef calc
    printf("%d\n",calc(a + b, 12));
    }
    int calc(int p, int q)
    {
    return p / q + p;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    -21 -5