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

Akshay Kadiyam said:   16 hours 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

Aniruddha giri said:   5 days 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.

Pes university said:   1 week 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
*/

Aashiya said:   2 months ago
Their is 5 times india fix is printed before the break of for loop..

TP.Swamy said:   4 years ago
Continue will throw the controller to the beginning of the loop while break will terminate the loop.
(7)

Laljijosh said:   5 years ago
Ans 0 is True.

Because x= -1
Negative value stored in 2'nd compliment.
(-1 ) 2nd compliment value is definatly x>10.


And for loop condition is x<=10.
Condition False and out of the loop.

So, the Ans is 0.
(26)

Seghrajeshwar said:   6 years ago
Hello ,please give me the suggestion for this.

#include<stdio.h>
int a,b,z,c;
float x=0.00,y;
float value=200;
void main()
{
x=value/200;
a=x;
y=x-a;
b=23*y;


for(z=0;z<23*a;z+=23)
{
printf("\n Z:%d ",z);
}
if(z<=z*a)
{
c=z;
z=c+b;

In a above code, I want a 23 value print on printf line. Now I am getting the 0 value. How to predict it? please tell me.
(3)

Vadivel said:   6 years ago
#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=18; x++)
{
if(x<5)
printf("\nIndiaBIX");
else
break;
printf("\nIndiaBIX");

}
return 0;
}
Output is 12.

Please explain.
(2)

Rohan said:   6 years ago
@All.

According to my knowledge.

#include<stdio.h>
int main()
{
int x;
for(x=-1; x<=10; x++)

/* (i) for loop is initialized with x=-1 and condition x<=10............... */
{
if(x < 5)
continue;

/* (i) First time ->
if (-1<5) , condition true -> continue statement transfer the control to for loop...
(ii) Last time ->
if (5<5) , condition false -> the else part will execute....
*/

else
break;

/* (i) -> the break statement make sure the for loop is terminated.........
(ii) -> it will not print IndiaBix because for loop has been terminated.............. */

printf("IndiaBIX");
}
return 0;
}
(5)

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


Post your comments here:

Your comments will be displayed after verification.