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;
}
Infinite times
11 times
0 times
10 times
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
142 comments Page 8 of 15.

Satti babu said:   1 decade ago
It will continue every time when x<5 that means it goes into again starting loop then when it is greater than 5 it will break that means exit from loop and gives out put 0 times.

Kondorpa said:   1 decade ago
can anyone please explain me the output?

#include<stdio.h>
main()
{
int p=5;
printf(" %d %d %d ",p,p++,++p);
}

Output is, as per indiabix.com compiler is 7 6 7

Swarup said:   1 decade ago
Since the continue transfers the flow of program at the starting of the loop and break statement transfers the flow of program outside the loop it will be printed for 0 times.

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.
(12)

Aminul said:   1 decade ago
#include<stdio.h>
int main()
{
int b=5;
int c= ((b++) + (++b) + (++b) + (++b));
printf("%d",c);
return 0;
}


I think the output will be 5+7+8+9 = 29.

Rajan said:   1 decade ago
Continue is for break current iteration. So that it gets increments and avoids the further steps and break is for break current loop. Therefore the loop is terminated.

RAJASHEKER.T said:   1 decade ago
Whenever x=5, it goes to else part.
In that else part break statement is there.
So break statement, breaks the forloop and come out of the loop.
So there is no output.

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.

Himanshu said:   1 decade ago
Hi agi. No matter you take value of i=1 or something else only the value inside the loop will be executed. So take i=1 or 100 or 200 loop will work for i=-1.

Sriram kumar 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.


Post your comments here:

Your comments will be displayed after verification.