Example Using the do Statement

The following statement prompts the user to enter a 1. If the user enters a 1, the statement ends. If not, it displays another prompt.

#include <stdio.h>
 
int main (void)
{
   int reply1;
 
   do
   {
      printf("Enter a 1\n");
      scanf("%d", &reply1);
   } while (reply1 != 1);
 
   return(0);
}


do Statement