Top

Discussion

What will be the output of the following C code?

#include
enum sanfoundry
{
    a,b,c=5
};
enum sanfoundry s;
main()
{
    c++;
    printf("%d",c);
}

 

  • A.Error
  • B.5
  • C.6
  • D.2

Answer: A

The above code results in an error because it is not possible to modify the value of enum constants. In the above code, we have tried to increment the value of c. This results in an error.

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

Post your comment