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 7 of 15.

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

Yogesh Sharma said:   1 decade ago
The printf Code Line is unreachable in the function

As The control from the if Statement is revert back to For loop increment till x<5 and as it become greater than 5 it stop executing the program.

That is in any circumstances the Printf Code is not executing.

Hence Option C is correct

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.

Kalaivani said:   1 decade ago
Else statement should not be followed by break;.

If break is used in else statement it returns nothing.

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.

Samikshya said:   1 decade ago
thanks to everyone

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.


Post your comments here:

Your comments will be displayed after verification.