0
Why is the output showing " time limit exceeded" when i run this program ?
#include <stdio.h> int main() { int num = 5; while (num > 0) { if (num == 3) continue; printf("%d\n", num); num--; } }
2 Answers
+ 5
That's because of the continue statement inside if block.
When num gets equal to 3, the if condition evaluates to true so the below code is skipped.
So, there will be no decrement in the value of num.
So, the num will have again the same value(3) and below code will be skipped.
This way it became an infinite loop, num will never get decremented to 0.