Loop Control Statements

Loop control statements in C programming are used to change execution from its normal sequence.

Name Description
break statement the break statement is used to terminate the switch and loop statement. It transfers the execution to the statement immediately following the loop or switch. 
continue statement continue statement skips the remainder body and immediately resets its condition before reiterating it.
goto statement goto statement transfers the control to the labeled statement.

C – Loops

Loops in programming are used to repeat a block of code until the specified condition is met. A loop statement allows programmers to execute a statement or group of statements multiple times without repetition of code.

C




// C program to illustrate need of loops
#include <stdio.h>
  
int main()
{
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
    printf( "Hello World\n");
      
    return 0;
}


Output

Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World

There are mainly two types of loops in C Programming:

  1. Entry Controlled loops: In Entry controlled loops the test condition is checked before entering the main body of the loop. For Loop and While Loop is Entry-controlled loops.
  2. Exit Controlled loops: In Exit controlled loops the test condition is evaluated at the end of the loop body. The loop body will execute at least once, irrespective of whether the condition is true or false. do-while Loop is Exit Controlled loop.

 

Loop Type Description
for loop first Initializes, then condition check, then executes the body and at last, the update is done.
while loop  first Initializes, then condition checks, and then executes the body, and updating can be inside the body.
do-while loop do-while first executes the body and then the condition check is done.

Similar Reads

for Loop

...

While Loop

for loop in C programming is a  repetition control structure that allows programmers to write a loop that will be executed a specific number of times. for loop enables programmers to perform n number of steps together in a single line....

do-while Loop

...

Loop Control Statements

While loop does not depend upon the number of iterations. In for loop the number of iterations was previously known to us but in the While loop, the execution is terminated on the basis of the test condition. If the test condition will become false then it will break from the while loop else body will be executed....

Infinite Loop

...