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.
Aniruddha giri said:
1 year ago
Here, printf("IndiaBIX");: this statement is intended to print "IndiaBIX" but it's placed after the break statement. So it didn't print anything.
Correct me, If I'm wrong.
Correct me, If I'm wrong.
(12)
Akshay Kadiyam said:
1 year ago
Since -1<=10 for loop get initialised.
Also, -1 <5 if the condition is true.
The printf("IndiaBIX"); statement gets skipped because of the continue statement that immediately follows it.
Continue statement directly goes to the next iteration skipping the code below it so printf does get executed
Also, -1 <5 if the condition is true.
The printf("IndiaBIX"); statement gets skipped because of the continue statement that immediately follows it.
Continue statement directly goes to the next iteration skipping the code below it so printf does get executed
(9)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers