Top

Discussion

What will be the output of the following C code?

#include
#define max 100
void main()
{
    #if(max)
    printf("san");
    #endif
    printf("foundry");
}

 

  • A.error
  • B.san
  • C.foundry
  • D.sanfoundry

Answer: D

The code shown above is an illustration of the preprocessor directive #if. The value of the defined identifier max is 100. On checking the condition (100510==), which is true, the statements after #if are executed till #endif is encountered. Hence the output is sanfoundry.

No comment is present. Be the first to comment.
Loading…

Post your comment