Top

C Preprocessor

1.

Which of the following are C preprocessors?

Answer: D

No answer description available for this question.

Enter details here

2.

What is the output of this program?

#include  
#define x 3
int main()
{
  int i;
  i = x*x*x;
  printf("%d",i);
  return 0;
}

 

Answer: A

No answer description available for this question.

Enter details here

3.

What will be the output of the following C code?

#include
#define san 10
main()
{
    #ifdef san
    #define san 20
    #endif
    printf("%d",san);
}

 

Answer: B

In the code shown above, if the identifier san is defined, then its value is redefined and changed to 20. It is then printed. Hence the output is 20.

Enter details here

4.

#include 
#define X 3
#if !X
    printf("Geeks");
#else
    printf("Quiz");
  
#endif
int main()
{
        return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

5.

What will be the output of the program?

#include
#define MAN(x, y) ((x)>(y)) ? (x):(y);

int main()
{
    int i=10, j=5, k=0;
    k = MAN(++i, j++);
    printf("%d, %d, %d\n", i, j, k);
    return 0;
}

 

Answer: A

No answer description available for this question.

Enter details here

6.

 

Output?

#include 
#define f(g,g2) g##g2 
int main() 
{ 
   int var12 = 100; 
   printf("%d", f(var,12)); 
   return 0; 
}

 

Answer: A

No answer description available for this question.

Enter details here

7.

What is the output generated by the following code?
    #define square (a) (a*a)     printf("%d", square (4+5) ) ;

Answer: C

the output generated by the following code is 29.

Enter details here

8.

What will be the output of the following C code?

#include 
    int main()
    {
        int one = 1, two = 2;
        #ifdef next
        one = 2;
        two = 1;
        #endif
        printf("%d, %d", one, two);
    }

 

Answer: B

No answer description available for this question.

Enter details here

9.

What will be the output of the program?

#include
#define SQUARE(x) x*x

int main()
{
    float s=10, u=30, t=2, a;
    a = 2*(s-u*t)/SQUARE(t);
    printf("Result = %f", a);
    return 0;
}

 

Answer: A

No answer description available for this question.

Enter details here

10.

What will be the output of the program?

#include
#define str(x) #x
#define Xstr(x) str(x)
#define oper multiply

int main()
{
    char *opername = Xstr(oper);
    printf("%s\n", opername);
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

Loading…
Tags: C Preprocessor Questions and Answers || C Preprocessor MCQ Questions and Answers || C Preprocessor GK Questions and Answers || C Preprocessor GK MCQ Questions || C Preprocessor Multiple Choice Questions and Answers || C Preprocessor GK || GK on C Preprocessor || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming