/ / do while loop in C Program, Syntax and Flowchart

do while loop in C Program, Syntax and Flowchart

In this tutorial, we will learn briefly about the do-while loop in c programming then understands the flow chart, Program in C. In previous tutorial learned while loop & for loop in this both the test condition occurs at the top but in this test expression occurs at the bottom.

Loop is used to repeat the block of statements until the given test expression or test condition return false. Also, learn about c flow controls 


IMPORTANT NOTE: In this, condition occurs at the end of the loop, so the body (All Statements) in the loop executes once before the condition is tested.

do-while Loop Syntax

Here I shared do while loop syntax and you easily understand how loop executes and statements loop inside loop body.

variable initialization //eg. i=1;
do{
    //All Statements
    // Variable Increment/Decrement eg. i++;       
}while( test expression )

do-while Flowchart Diagram 

Below I shared flowchart diagram for the do-while loop in c programming. So, It is easy for you to understands flow chart.


do while in c programming and flow chart
Flow chart of do while loop in c



Example


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



When the above code is compiled and executed, it produces the following output 




 Value of count is:1
 Value of count is:2



In the Above article, We discuss do-while loop in c programming and flowchart, and if you have any doubt in the article then comment below.

Happy Coding 😊


do while loop in C Program, Syntax and Flowchart do while loop in C Program, Syntax and Flowchart Reviewed by Veer Bhadra Singh on April 17, 2020 Rating: 5

No comments:

Powered by Blogger.