Do-while Loop Explained with Syntax and Examples of C programming
In general, statements in a program are executed sequentially. The first statement is executed first, followed by the second, and so on. But in some situations, it is required to execute a block of code over and over again. Loops are used to execute a block of statements a specified number of times until a condition is met.
C supports the following types of loops:
Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop in C programming checks its condition at the bottom of the loop.
A do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time since the loop is executed once before the condition is tested.
} while (condition);
In do…while loop, while should be terminated using;
To print all numbers from 50 to 30.
int n; n=50;