Top

C Preprocessor

21.

What is the output of this program?

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

 

Answer: D

Operators enjoys priority / is given more priority over *. In this program the execution takes place in this format. 27 / square(3) 27 / 3*3 27 / 3*3 9 * 3 27

Enter details here

22.

What will be the output of the following C code?

#include
#define INDIA 1
#define US 2
#define CC US
main()
{
    #if CC==INDIA
    printf("Rupee");
    #elif CC==US
    printf("Dollar");
    #else
    printf("Euro");
    #endif 
}

 

Answer: C

The output of the code shown above is Dollar. Since the macro CC is defined as US at the beginning of the code, it satisfies the condition #elif(CC==US). Hence “Dollar” is printed.

Enter details here

23.

Tn a macro call the control is passed to the macro.

Answer: B

No answer description available for this question.

Enter details here

Answer: A

No answer description available for this question.

Enter details here

25.

What will be the output of the program?

#include
#define MAX(a, b) (a > b ? a : b)

int main()
{
    int x;
    x = MAX(3+2, 2+7);
    printf("%d\n", x);
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

Answer: C

It is primarily used for running a function upon exiting the program.

Enter details here

27.

#include 
#if X == 3
    #define Y 3
#else
    #define Y 5
#endif
 
int main()
{
    printf("%d", Y);
    return 0;
}

What is the output of the above program?

Answer: B

No answer description available for this question.

Enter details here

28.

What will be the output of the following C code?

#include
#define hello 10
main()
{
    #ifdef hello
    #undef hello
    #define hello 100
    #else
    #define hello 200
    #endif
    printf("%d",hello);
}

 

Answer: C

No answer description available for this question.

Enter details here

29.

A header file contains macros, structure declaration and function prototypes.

Answer: A

True, the header file contains classes, function prototypes, structure declaration, macros.

Enter details here

30.

What will be the output of the program?

#include
#define MESS junk

int main()
{
    printf("MESS\n");
    return 0;
}

 

Answer: B

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