What is the output of this C code?
int foo();
int main()
{
int i = foo();
}
foo()
{
printf("2 ");
return 2;
}
Answer: A
Correct answer: 2
The prototype says int foo(), and the definition, which gives no return type, defaults to int - so the two agree. The program compiles and prints 2.
Please log in or register to report this question.