Home C Programming Language / Programs / continue statement in for loop
🚀 Programming Example

continue statement in for loop

👁 1,044 Views
💻 Practical Program
📘 Step Learning

The continue statement in C programming works somewhat like the break statement. Instead of forcing termination, it forces the next iteration of the loop to take place, skipping any code in between.

For the for loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while and do...while loops, continue statement causes the program control to pass to the conditional tests.

 

syntax

The syntax for a continue statement in C is as follows −

continue;

Flow Diagram with syntax

 

for loop continue
Syntaxfor loop continue

💻 Program Code

#include <stdio.h>
void main ()
{ 
int a =  1; 
 
while( a <= 10){ 
	 	
 	if(a == 5){ 
 	  a++;
      continue;
	 } 

 printf("value of a: %d\n", a);	
 a++; 	  
} 
 
}
                        

🖥 Program Output

value of a: 1
value of a: 2
value of a: 3
value of a: 4
value of a: 6
value of a: 7
value of a: 8
value of a: 9
value of a: 10
Press any key to continue . . .
                            

📘 Explanation

when the value of a reaches to 5 then its continue, for that 5 is not printed.
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.