What is the output of code given below?
enum m{JAN, FEB, MAR};
enum m foo();
int main()
{
enum m i = foo();
printf("%d\n", i);
}
int foo()
{
return JAN;
}
Answer: A
Correct answer: Compile time error
The prototype declares enum m foo(); but the definition is written int foo(). The two conflict, and the compiler rejects the program - even though an enumeration is represented as an integer, the declared types must match.
Please log in or register to report this question.