Top

Discussion

What will be the output of the following C code?

#include
#define hello 
main()
{
    #ifdef hello
    #define hi 4
    #else
    #define hi 5
    #endif
    printf("%d",hi);
 
}

 

  • A.4
  • B.5
  • C.45
  • D.error

Answer: A

The code shown above illustrates #define, #ifdef, #else, #endif. Since the identifier hello is defined (condition of #if is true), another identifier names hi is defined and it’s value is 4. If hello was not defined, then the value of hi would be 5.

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

Post your comment