Do-while Loop in C language
“Try and Fail, but never fail to try!! “
In last article – While Loop in C language we have seen while loop in detail.
Today we are going to have a look on do while loop.
Soo let’s start quickly 🙂
What is Do while loop???
• A do…while loop is similar to a while loop, except the fact that it is guaranteed to execute at least one time. Because it is a exist controlled loop. Condition is checked at the end of loop.
•Syntax of do while loop is as follows👇
} while( condition );
• Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop executes once before the condition is tested.
• If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop executes again. This process repeats until the given condition becomes false.
•Flowchart:- now let’s try to understand with the help of flowchart below.
Now let’s move towards some examples.
Q1) Write a C program to display numbers 1 to 10.
Q2) Write a C program to display numbers from 10 to 19.
Q3) Write a C program to display multiplication table of given number.
Q4) Write a C program to display factorial of given number.
Q5) Write a C program to print multiple of 3 from 1 to 100.
We have very good series on C – language, kindly please have a look – https://knowledge-junction.com/category/c-language/
Soo will call it a day!
Hope you all must have got an idea about do while loop.
And yaa don’t forget to put comments 🙂
Soo see you all in next article….. Till then good bye. Have a amazing day ahead 🙂