Top

Discussion

What is the output of this C code?

#include 
    int main()
    {
        enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};
        printf("PEACH = %d\n", PEACH);
    }

 

  • A.PEACH = 3
  • B.PEACH = 4
  • C.PEACH = 5
  • D.PEACH = 6

Answer: C

In enum, the value of constant is defined to the recent assignment from left.

Output:
$ cc pgm1.c
$ a.out
PEACH = 5

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

Post your comment