Top

Discussion

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 
}

 

  • A.Euro
  • B.Rupee
  • C.Dollar
  • D.Error

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.

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

Post your comment