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.

Gururaj said:   8 years ago
Actlly almost all we are not using -1 for initilizng -1 in for loop.

Pes university said:   1 year ago
#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s>3&&s<10)
continue;
printf("\n%d\t",s);
}
}

*/Here it is usually you're giving s=0 and then s++<10;means s++=1;

So, condition true go to the while loop that will print 1 2 3 and then you're giving that s>3 and s<10 continue it will continue until the last element that is 9 if you are given as here then it will print the 1 2 3 9 but you given s++.

So, the output is;
1
2
3
10
*/


Post your comments here:

Your comments will be displayed after verification.