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

Discussion

Point out the error (if any) in the following C code?

#include <stdio.h>
enum hello
{
    a,b,c;
};
main()
{
    enum hello m;
    printf("%d",m);
}

 

  • A.No error
  • B.Error in the statement: a,b,c;
  • C.Error in the statement: enum hello m;
  • D.Error in the statement: printf(“%d”,m);

Answer: B

Correct answer: Error in the statement: a,b,c;

The enumerator list must not end with a semicolon inside the braces - a, b, c is a comma-separated list, and the only semicolon belongs after the closing brace. Writing a,b,c; is a syntax error.

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

Post your comment

Please log in or register to post a comment.