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 14 of 15.
Aliimran224 said:
1 decade ago
Here,
i = i+2*i+1 [Because i++ = i+1].
Now i = 1+2*1+1.
i = 4(Ans).
i = i+2*i+1 [Because i++ = i+1].
Now i = 1+2*1+1.
i = 4(Ans).
Madhu Chandra said:
1 decade ago
The continue statement under if condition will keep on running the executing for loop by increment 1 and then after 6 iterations the x value becomes 5 by increment 1 and in 7th iteration it will fail, then go break out from loop.
Jayapraksah said:
1 decade ago
When the condition is true it will skip the further program by continue. If the condition getting false it will get off the block by executing break statement.
Abhishek Kumar said:
1 decade ago
The if block will execute upto x=4, when it is x=5, then the if statement become false and it will go to else block, where break statement is given, the break will terminate the program and takes the control out of the program.
Therefore, there will be no output for this program. Option (C) is correct.
Therefore, there will be no output for this program. Option (C) is correct.
Kamlesh said:
1 decade ago
I am not getting any thing.
Vaibhav said:
1 decade ago
Please anyone can explain me this program:
#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s>3&&s<10)
continue;
printf("\n%d\t",s);
}
}
#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s>3&&s<10)
continue;
printf("\n%d\t",s);
}
}
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?
Abhishek said:
10 years ago
After the break statement we come out from the loop that's why the answer should be 0 times.
Bhavna Bhoir said:
9 years ago
Break statement is used to take control of execution abruptly out of the loop.
When continue statement is executed, then the control of execution simply continue to next iteration of the loop.
When continue statement is executed, then the control of execution simply continue to next iteration of the loop.
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?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers