google.com, pub-8786015629279405, DIRECT, f08c47fec0942fa0 Do-While Loop in C

Do-While Loop in C

0

 As we discuss about the Looping in the Previous section, Looping is a process which is used to execute a set of statements repetitively when a certain condition true.



C provides three ways to execute the loops. While all of the ways offer similar basic functionality, but differ in syntax and condition.


Do-While Loop: 

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.

do...while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time. because do-while checks the test condition after the execution or exit of the loop body.



Syntax:

Initialization

do
{
Statements or Body of Loop;
Increment/ Decrement;
}while(Test condition);




1.Initialization: We initialize the variable in use here. It marks the beginning of a for loop. It is possible to use an already declared variable, or to declare a variable, local to loop only.

2. Test Condition: It is used to test a loop's exit condition. They have to return a boolean value. It is also an Entry Control Loop, since the condition is checked before the loop statements are executed.

3. Execution of statements: Once the condition is evaluated to true, the statements are executed in the body of the loop.

4.Increment / Decrement: Used for next iteration to change the variable.

5. Loop termination: When the state is incorrect the loop stops signaling the end of its cycle of life.

Flow Chart of Do-While Loop :


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Thank you for your interest 😊

We will back shortly after reviewing...

Thank you for your interest 😊

We will back shortly after reviewing...

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top