do while Loop in C Language
×


do while Loop in C Language

343

In C, the do-while loop is a control structure that repeatedly executes a block of code as long as a specified condition remains true.

Unlike the while loop, the do-while loop guarantees the execution of the code block at least once, even if the condition is initially false.

This ensures that the code inside the loop is executed before the condition is evaluated, making it suitable for situations where the block must execute at least once regardless of the condition's initial state.

 The do-while loop starts with executing the block of code.

After each, execution it checks specific conditions.

If the condition is True, the loop continues to execute the block of code.

If the condition is False, the loop gets terminated.

This loop is useful when you want to execute a certain block of code at least once, even if the condition is true or false.

do while loop execution 

Syntax of do while loop 

do{
//block of code is executed here


}while(condition);

Example:

#include<stdio.h>
int main()
{
	int A = 8;
	do{
	printf("%d\n", A);
	A++;
	}while( A<= 10);
	return 0;
}
Output:

8
9
10


Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments