C break and continue

What is a break statement in C?

A break statement has a wide variety of application in C. Have you ever seen a premature exit of any loop in your program? The break statement will help us to jump out of the loop immediately. Basically for, while, do while, and switch loop implements break statements and sometimes If statement also uses it. Break statements will cause innermost enclosing loop or switch to jump out of the loop. The break statement will usage is illustrated below.


Now let’s see how we can implement break statement in c programs.

Likewise, the output of the above code will be:


These numbers are the numbers before using the break statement.

What is Continue Statement in C?

Like break statement, continue statement is also a loop control statement. In comparison to the break statement, continue statement will not enable an exit from the loop. Whereas, the continue statement causes the loop to continue with the next iteration. It will make the program skip the statements that are in between. In short, we can say that the continue statement will allow the loop to continue and to execute the next iteration.

The syntax of the continue statement is given below:


Now let’s illustrate our first example for printing upper case letters A-Z and lower case numbers-z with their ASCII value.

Now let’s have a peek on the output of the above code.


A=65 B=66 C=67 D=68 E=69 F=70 G=71 H=72 I=73 J=74 K=75 L=76 M=77 N=78 O=79 P=80 Q=81 R=82 S=83 T=84 U=85 V=86 W=87 X=88 Y=89 Z=90 a=97 b=98 c=99 d=100 e=101 f=102 g=103 h=104 i=105 j=106 k=107 l=108 m=109 n=110 o=111 p=112 q=113 r=114 s=115 t=116 u=117 v=118 w=119 x=120 y=121 z=122




SHARE C break and continue

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *