Difference between while loop and do-while loop in C

Difference between while loop and do-while loop in C


C – do..while loop

Syntax of do-while loop

do
{
    //Statements 

}while(condition test);

Flow diagram of do while loop

C do while loop

Example of do while loop

#include 
int main()
{
	int j=0;
	do
	{
		printf("Value of variable j is: %d\n", j);
		j++;
	}while (j<=3);
	return 0;
}

Output:

Value of variable j is: 0
Value of variable j is: 1
Value of variable j is: 2
Value of variable j is: 3