Do while loop: Post-tested loop

Do While Loop Post Tested Loop Sourav Purkait

Introduction:

Do while loop is a post – tested loop. It is similar to while loop expect it executes its body at least once  weather the condition is true or false. The do while loop terminates when the text expression is evaluated to be zero.

Syntax:

do 

{

    // statement;

}

while (condition );

Flow chart:

Example:

#include<stdio.h>  

int main ()

{    

int i=1;      

do

{    

      printf(“%d  “,i);    

      i++;    

}

  while(i<=10);   

  return 0;  

}    

Output: 1 2 3 4 5 6 7 8 9 10

Conclusion:

The do-while loop is mainly used in the case where we need to execute the loop at least once. The do-while loop is mostly used in menu-driven programs where the termination condition depends upon the end user.

AUTHOR- SOURAV PURKAIT

Disclaimer: The author(s) of this blog are solely responsible for the content posted. The blog platform serves as a medium for their expression, and the platform administrators assume no liability for the accuracy or legality of the content.
Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!