May 29, 2020

While loop In C

In privious post we learned for loop, in this post we will learn working of  while loop.
While loop is  used when you want to execute a block of code repeatedly with a checked condition before making an iteration. In simple language while loop is a entry  controlled looping statement.

Syntax of while loop -

Syntax of while loop is shown above.

Example program of while loop: 

void main()
 int i=1;
 printf(" Hello ");

Here, until test counter condition is true the statements within while loop exicuts, means until i is less than or equal to 10 it prints Hello, means it print hello 10 times. when condition becomes false controle will be transferred to the next line after the loop.

Above program shows the following Output:

Share This:    Facebook Twitter


Post a Comment

If you have any doubts, please discuss here...