Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

About continue

+3 votes
asked Aug 26 by SARAN V (150 points)
#include<studio.h>
int main()
{
int i=0;
for(;;)
{
if(i==10){
continue;
}
printf("%d",++i);
}}
This above code makes the output as without print anything.But by my logic it prints the value from 1 to infinite times except 10.The continue statement doesn't run the below code after continue statement but the continue statement is inside the if condition then why it shouldn't run the statement that are below the continue statement?

1 Answer

0 votes
answered Aug 31 by xDELLx (10,380 points)
printf uses buffered I/O .

data is stored in internal buffers, waiting for the buffer to fill completely ,before data is flushed to console   or files.

In case of this code ,the data doesnt compeletly fill the printf buffer &printf is waiting indefinitely for the buffer to fill.

Adding a new line char (\n) will force the buffer to flush(write) on console.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...