Looping statement in C Programming

Posted on

Looping assertion

Looping assertion are the statements execute a number of assertion repeatedly a number of variety of instances. In C programming language there are three forms of loops; whereas, for and do-while.

Why use loop ?

When you want to execute a block of code a number of variety of instances then you want to use looping idea in C language.

Benefit with looping assertion

  • Cut back size of Code
  • Take much less reminiscence house.
  • Burden on the developer is lowering.
  • Time consuming course of to execute this system is lowered.

loop - Looping statement in C Programming

Sorts of Loops.

There are three sort of Loops accessible in ‘C’ programming language.

  • whereas loop
  • for loop
  • do..whereas

Distinction between conditional and looping assertion

Conditional assertion executes solely as soon as in this system the place as looping statements executes repeatedly a number of variety of time.

Whereas loop

In whereas loop First verify the situation if situation is true then management goes contained in the loop physique different sensible goes outdoors the physique. whereas loop will probably be repeats in clock sensible route.

while loop - Looping statement in C Programming


Observe: If whereas loop situation by no means false then loop turn into infinite loop.

Instance of whereas loop


For loop

for loop is a press release which permits code to be repeatedly executed. For loop comprises 3 elements Initialization, Situation and Increment or Decrements.

for loop - Looping statement in C Programming

Instance of for loop



A do-while loop is just like some time loop, besides {that a} do-while loop is execute no less than one time.

A do whereas loop is a management movement assertion that executes a block of code no less than as soon as, after which repeatedly executes the block, or not, relying on a given situation on the finish of the block (in whereas).


do while loop - Looping statement in C Programming

When use do..whereas Loop

When we have to repeat the assertion block no less than 1 time then we use do-while loop.

Instance of do..whereas loop


Nested loop

In Nested loop one loop is place inside one other loop physique.

When we have to repeated loop physique itself n variety of instances use nested loops. Nested loops may be design upto 255 blocks.