Do While Loop In C Language With Examples

do while:

The terminating condition in the for and while loops is always tested before the body of the loop is executed -- so of course the body of the loop may not be executed at all. In the do while statement on the other hand the statement body is always executed at least once as the condition is tested at the end of the body of the loop.

  statement body ;
}  while ( condition ) ;
do while loop in c language

For Example : To read in a number from the keyboard until a value in the range 1 to 10 is entered.

int i ;
  scanf( "%d\n", &i ) ;
  _flushall() ;
}   while ( i < 1 && i > 10 ) ;

In this case we know at least one number is required to be read so the do-while might be the natural choice over a normal while loop.

#do_while_loop_in_c_language,do_while_loop_in_c #do_while_c #do_while #syntax_of_do_while_in_c

(New page will open, for Comment)

Not yet commented...