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


Post your comments here:

Your comments will be displayed after verification.