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 11 of 15.
Harsha said:
1 decade ago
When break is encountered in loop then the control directly jumps to the first statement after the loop.
Keshav saini said:
1 decade ago
Here printf ("IndiaBIX") ; is unreachable code. Because break keyword is stop the working of the block.
TP.Swamy said:
5 years ago
Continue will throw the controller to the beginning of the loop while break will terminate the loop.
(12)
K. Parthi said:
1 decade ago
The statement will be executed until x IS 5 THEN it terminates the loop by break, prints return 0.
Ramsan said:
1 decade ago
After the break statement, It will come out of the loop. Then it will not going to print IndiaBix.
Shweta said:
1 decade ago
Thanks fellas.
Actually I missed to notice that 'printf' is within 'for loop', and made mistake.
Actually I missed to notice that 'printf' is within 'for loop', and made mistake.
Amit said:
2 decades ago
The continue statement transfers the control to the next iteration in the loop (increment step).
Abhishek said:
1 decade ago
After the break statement we come out from the loop that's why the answer should be 0 times.
Mansi sharma said:
1 decade ago
x is declared as integer so it can not be initialised as x=-1 so program won't run.
Karthi said:
1 decade ago
The continue statement transfers the control to the next iteration in the loop
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers