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 9 of 15.
Ajeshbabu said:
1 decade ago
If x is <5 ,if condition will executed, other 6 then loop process is terminated, then return 0 will occur,then final result get 0 times loop occur
Karan said:
1 decade ago
When condition will satisfy means x<5 is true then break statement will be executed. And then control will not transfer on printf statement.
Sarasa said:
1 decade ago
The value of X is -1 so again and again to execute the loop to increase the value in X is minus value so infinte times to execute the loop.
Guna said:
1 decade ago
The program with using continue we get result.
But if using any body of while, do, for break statement (true or false) not get out put.
But if using any body of while, do, for break statement (true or false) not get out put.
Sudharsan said:
1 decade ago
The continue statement does not allow to execute statement that present after the continue statement and it allows next iteration.
Divyasree said:
1 decade ago
control never goes to printf("IndiaBix"); statement.. So there exists compilation error.. Hence the solution is 0 times
Siva said:
9 years ago
If condition false means it should be executed the else statements?
Then why is not printed one time? Can anyone explain to me?
Then why is not printed one time? Can anyone explain to me?
Bhargavi said:
1 decade ago
Since we use break statement it automatically comes out of the else loop, no matter whether it satisfies if condition or not,
Rakesh said:
1 decade ago
I have a doubt in this. Break statement in else block only exits from the else block or will it exits from the for loop?
Ayodhya Prasad said:
1 decade ago
Since loop will execute until condition is true. After break it will not execute. Hence it will not print the IndiaBix.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers