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 5 of 15.
Soumya said:
1 decade ago
Thnks to sandeep. Its correct.
Raju Naidu said:
1 decade ago
Hai,
The keyword 'continue' is used to skip the some statements and continuing the current process. In our programm till the x=5 it continuing the process once it's reached to 5 if condition getting false so else block will be execute but in else block we had break statement, so it breaks the loop and it will never go to print the indiabix so answer is 0 times.
The keyword 'continue' is used to skip the some statements and continuing the current process. In our programm till the x=5 it continuing the process once it's reached to 5 if condition getting false so else block will be execute but in else block we had break statement, so it breaks the loop and it will never go to print the indiabix so answer is 0 times.
Vadivelan said:
1 decade ago
Thanks Friends
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.
Purushottam kumar said:
1 decade ago
Here inside the program x is < 5, the "if" condition is true and continue is encountered so the loop continue inside 'for' execution without executing the following statements. and when the value of x becomes 5, 'break' is executed and the 'for' loop will be terminated , So 'IndiaBix' will not be printed even once because 'printf' will never executed.
Prajith&ratnaji said:
1 decade ago
Thank you very much for clearing our doubt.
Vivek said:
1 decade ago
No output will be there for this code.
DKBOSS said:
1 decade ago
This will printed one time ; please check your sequence and then discuss.
Disha said:
1 decade ago
Thanks to sandeep.
Anand kumar said:
1 decade ago
Thanks you for all...........
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers