do while statement in C
do while statement is an exit controlled looping statement. initialization, condition and updation are performed in separate lines. It executes at least once.
The syntax of do while statement is:
do is a keyword which specifies that do while statement has started
Initialize: In this part, we assign some value to the control variable which controls number of times the loop should execute.
Update: Increasing or decreasing the value of control variable comes under this part.
Statements are set of instructions which will repeatedly execute as long as condition evaluates to true.
while is a keyword to specify that do while has ended. It should be followed by a semicolon.
In the program, initially loop control variable k is assigned value 1.
Program enters the loop from keyword do.
Then printf(“\n%d”,k); will execute followed by statement k++.
k is then compared to 4 . It is less than 4, so program control jumps to keyword do.
This process repeatedly executes as long as condition part is true.