do while


do-while is similar to a while loop and used when a set of statements have to be repeatedly executed at least once untile a certain condition is reached. When we do not know exactly how many time a set of statement have to be repeated do while can be used.

Syntax:-
do
{
  statement….
  updating;
  while(condition);
}
Flowchart:-
do-while

W.A.P to print 1 to 5

#include<stdio.h>
#include<conio.h>
void main()
 {
  do
 {
  printf(“%d\n”,i);
  int i=1;
  i++;
 }
  while(i<=5);
  getch();
}

Output

1
2
3
4
5