Machine-translated by Google. Questions are authored in English.
Top

Discussion

What will be the output of the following C code?

#include <stdio.h>
enum sanfoundry
{
    a,b,c=5
};
int main()
{
    enum sanfoundry s;
    b=10;
    printf("%d",b);
}

 

  • A.Error
  • B.10
  • C.1
  • D.4

Answer: A

Correct answer: Error

b is an enumerator - a constant - so b = 10; is an assignment to something that is not an lvalue, and the compiler rejects it. Only an enum variable can be assigned to.

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

Post your comment

Please log in or register to post a comment.