Top

Discussion

What will be the output of the following C code?

#include
enum sanfoundry
{
    a=1,b,c,d,e
};
int main()
{
    printf("%d",b*c+e-d);
}

 

  • A.Error
  • B.7
  • C.2
  • D.4

Answer: B

Since arithmetic operations are allowed on enum constants, hence the expression given is evaluates. b*c+e-d = 2*3+5-4 = 6+5-4 = 7

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

Post your comment