While Loop Statement In C Language

while loop statement

The while loop is an entry controlled loop statement. The condition is evaluated, if the condition is true then the block of statements or statement block is executed otherwise the block of statement is not executed.

The WHILE Statement is used to carry out looping operations. Hence, the loop is executed until the expression evaluates to TRUE.

The General form of this statements is :

syntax:

Flowchart:

Example:



Output:

              
  1 2 3 4 5
              

Difference between while and do-while

do-while while
Condition is checked at the end of the loop. Condition is checked in the beginning of the loop.
Set of statements within the loop will be executed atleast once. If the condition is fals, the statements will not be executed even once.

Read Also: