do while statement in C
In do while statement initialization, condition and updation are performed in separate lines. This looping statement executes at least once.
The syntax of do while statement is:
do is a keyword which specifies that do while statement has started
Initialization is the way to assign some initial value to loop control variable which controls number of times loop should execute.This is the value from where do while loop starts.
Updation is to increase or decrease the value of loop control variable.
Statements refers to C language instructions which are part of do while statement.
while is a keyword to specify that do while has ended. It should be followed by a semicolon.
|Program of do while statement.|
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.