Sometimes it is necessary for the program to execute the statement several times. A loop executes a block of commands a specified number of times until a condition is met. In this tutorial, you will learn about all the looping statements of C programming, along with their use.



What Is Loop?

A computer is the most suitable machine for performing repetitive tasks and can perform a task thousands of times. Every programming language has the feature to instruct to do such repetitive tasks with the help of certain statements. The process of repeatedly executing a collection of statements is called looping. The statements get executed many times based on the condition. But suppose the condition is given in such logic that the repetition continues any number of times with no fixed condition to stop looping those statements. In that case, this type of looping is called infinite looping.

C supports the following types of loops:

All are slightly different and provide loops for different situations.

Figure - Flowchart of Looping:

C Loop Control Statements

Loop control statements are used to change the normal sequence of execution of the loop.

Statement Syntax Description
break statement break; It terminates loop or switch statements.
continue statement continue; It suspends the current loop iteration and transfers control to the loop for the next iteration.
goto statement goto labelName;

labelName: statement;

It transfers the current program execution sequence to some other part of the program.


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram