Programming Languages C Objective
Mar 08, 2013

What will be output of the following c code?

#include<stdio.h>
const enum Alpha
    {
      X,
      Y=5,
      Z
    }p=10;
int main()
  {
    enum Alpha a,b;
    a= X;
    b= Z;
    printf("%d",a+b-p);
    return 0;
   }

Choose the correct answer:
A) 5
B) 4
C) -4
D) -5
Detailed Explanation

Default value of enum constant X is zero and
Z = Y + 1 = 5 + 1 = 6
So, a + b – p
=0 + 6 -10 = -4

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback