Top

Discussion

What will be the output of the following C code?

#include
void main()
{
    #ifndef max
    printf("hello");
    #endif
    printf("hi");
}

 

  • A.hello
  • B.hellohi
  • C.error
  • D.hi

Answer: B

The code shown above illustrates the preprocessor directive #ifndef. If the identifier checked is not defined, then the statements following #ifndef are executed. Here, since the identifier max is not defined, the statement after #ifndef is executed. Hence the output is: hellohi

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

Post your comment