Top

Discussion

What will be the output of the following C code?

#include
#define max 100
main()
{
    #ifdef max
    printf("hello");
}

 

  • A.100
  • B.hello
  • C.“hello”
  • D.error

Answer: D

The code shown above results in an error. This is because the preprocessor #endif is missing in the above code. If the identifier is defined, then the statements following #ifdef are executed till #endif is encountered.

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

Post your comment