Discussion
What is the output of this C code?
int main()
{
int *p = NULL;
for (foo(); p; p = 0)
printf("In for loop\n");
printf("After loop\n");
}
Answer: B
Correct answer: Compile time error
foo is never declared or defined anywhere in this program. Under the current C rules an undeclared function is an error, and even where it is only a warning the missing definition would fail at link time. So the program does not run at all - the value of p is beside the point.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development