- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between while and do-while Loop
In this post, we will understand the difference between the ‘while’ loop and the ‘do-while’ loop.
while condition
The controlling condition here appears at the beginning of the loop.
The iterations do not occur if the condition at the first iteration results in False.
It is also known as an entry-controlled loop
There is no condition at the end of the loop.
It doesn’t need to execute at least one.
Example
while ( condition){ statements; //body of loop }
Following is the flowchart of while loop −
do-while condition
The controlling condition is present at the end of the loop.
The condition is executed at least once even if the condition computes to false during the first iteration.
It is also known as an exit-controlled loop
There is a condition at the end of the loop.
Example
do { statements; // body of loop. } while( Condition );
Following is the flowchart of do-while loop −
- Related Articles
- Difference Between for and while loop
- What are the differences between while loop and do-while loop in Java?
- Difference between for loop and while loop in Python
- do…while loop vs. while loop in C/C++
- Java do-while loop example
- Java infinite do-while loop
- Do-while loop in Arduino
- The do…while loop in Javascript
- How to use C# do while loop?
- Difference between while(1) and while(0) in C/C++
- Difference between while(1) and while(0) in C language
- How to use ‘do while loop’ in Java?
- What is do...while loop statement in JavaScript?
- Java while loop
- while and do-while in Dart Programming

Advertisements