Iteration statement cont.
syntax:
- do <statement>
- while ( <expression> )
- <next statement>
semantic:
- a variant of while statement, instead of making its test at the top of the loop, it makes it at the bottom.
example:
- /* as long as a nonpositive integer is entered, the user will be notified with a error message; control will exit the loop only after a positive integer has been enter */
do
{ printf("Input a positive integer: ");
scanf("%d",&n);
if (error = (n <= 0))
printf("\nError: Negative value not entered\n");
} while (error)