C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - General Questions (Q.No. 1)
1.
How many times "IndiaBIX" is get printed?
#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)
{
if(x < 5)
continue;
else
break;
printf("IndiaBIX");
}
return 0;
}
Discussion:
142 comments Page 15 of 15.
Amit said:
1 decade ago
The continue statement transfers the control to the next iteration in the loop (increment step).
Srinivasa.S said:
2 decades ago
The condition x<5 is true until x=5, so the true block executed. The code after the continue statement(including printf("IndiaBIX");) will not executed and go to increment step(x++). Again the loop is continued.
When x=5, then else block executed, it has break statement, So loop is terminated.
Here the control never go to printf("IndiaBIX"); statement.
When x=5, then else block executed, it has break statement, So loop is terminated.
Here the control never go to printf("IndiaBIX"); statement.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers