Top

Discussion

What is the output of this C code?

#include 
    enum birds {SPARROW, PEACOCK, PARROT};
    enum animals {TIGER = 8, LION, RABBIT, ZEBRA};
    int main()
    {
        enum birds m = TIGER;
        int k;
        k = m;
        printf("%d\n", k);
        return 0;
    }

 

  • A.Compile time error
  • B.1
  • C.8

Answer: D

m is an integer constant, hence compatible.

Output:
$ cc pgm5.c
$ a.out
8

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

Post your comment