Loop Statement in C

Facebooktwitterredditpinterestlinkedinmailby feather

Loop statement is used to execute one or more statement repeatedly multiple times.

There are three types of loops in C language.

Why use loop?

We can use loop because it executes a block of code multiple times and it reduces the length of the code.

Example:  Let suppose we have to print counting 1to 50 then we have to use 50 times lines of code but if we use loop then print it by 2 or 5 lines of code.

  • for loop
  • while loop
  • do while loop

Difference between conditional and looping statement:

The conditional statement executes only once in the program but looping statements executes repeatedly several number of times.

for Loop

The for loop statement is used to execute the code until a condition is false. In this section, there are 3 parts initialization, condition and increment or Decrements.

 The following syntax of for Loop:



Example 2

//To print any childish table of any number


While Loop

While loop is an entry-controlled loop statement. The basic format of the while statement is:





Note: While loop is used when the number is uncertain or unknown.



Do while Loop

Do while loop is used to execute the program. In do while loop, the first part of the execution is body then evaluate the text condition. If the condition is true, the body of the loop is executed again and again until the condition becomes false.


Let us consider the flow chart of the C program

Let us consider an example:

Facebooktwitterredditpinterestlinkedinmailby feather

Leave a Comment