logo

CuriousTab

CuriousTab

C Preprocessor problems


  • 1. Will the following program print the message infinite number of times?
    #include<stdio.h>
    #define INFINITELOOP while(1)
    
    int main()
    {
        INFINITELOOP
        printf("CuriousTab");
        return 0;
    }
    

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 2. Will the program compile successfully?
    #include<stdio.h>
    
    int main()
    {
        #ifdef NOTE
            int a;
            a=10;
        #else
            int a;
            a=20;
        #endif
        printf("%d\n", a);
        return 0;
    }
    

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 3. Would the following typedef work?
    typedef #include l;

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 4. Will the program compile successfully?
    #include<stdio.h>
    #define X (4+Y)
    #define Y (X+3)
    
    int main()
    {
        printf("%d\n", 4*X+2);
        return 0;
    }
    

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 5. It is necessary that a header files should have a .h extension?

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 6. Will the program compile successfully?
    #include<stdio.h>
    
    int main()
    {
        printf("India" "CURIOUSTAB\n");
        return 0;
    }
    

  • Options
  • A. Yes
  • B. No
  • Discuss
  • 7. Will it result in to an error if a header file is included twice?

  • Options
  • A. Yes
  • B. No
  • C. It is compiler dependent.
  • Discuss

First 2 3 4