Discussion
Output?
#include <stdio.h>
int main()
{
int c = 5, no = 10;
do {
no /= c;
} while(c--);
printf ("%d\n", no);
return 0;
}
Answer: B
Correct answer: Runtime Error
The loop divides no by c and then tests c--, so c falls 5, 4, 3, 2, 1, 0. On the pass after the test that saw c equal to 1, c is 0 - and no /= 0 is integer division by zero, which the hardware traps. The compiler cannot see it, so it is a run-time fault.
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