Discussion
What will be the output of the following C code?
int main ()
{
printf("starting of program\n");
printf("program exits\n");
exit(0);
printf("program ends\n");
return(0);
}
Answer: B
Correct answer: starting of program program exits
exit(0) terminates the program immediately, so the third printf and the return are never reached. Only the first two lines appear. Unlike return from main, exit can be called from anywhere and ends the whole program.
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