Explain do-while statement with syntax and example
C's do-while statement has the form:
do
statement;
while (expression);
For example:
int x=3;
main()
{ do {
printf("x=%d$\setminus$n",x-);
}
while (x>0);
}
..outputs:-
x=3
x=2
x=1
NOTE: The postfix x- operator which uses the current value of x while printing and then decrements x.
Labels: C