Course Content

  • 2.10 do_while
  • 2.10 for
  • 2.10 while

Course Content


The while loop statement generates a loop in which a block is executed until a condition evaluates to false. Unlike the while loop, the do-while loop always performs at least one execution of the statement before evaluating the expression.

Syntax: while(condition); do statement(s); Because the conditional expression appears at the conclusion of the loop, the loop's statement(s) run once before the condition is tested. If the condition is true, the flow of control returns to do, and the loop's statement(s) run again.

While vs. Do When the condition is checked is a question of when. A while loop first verifies the condition before running the loop. The loop is executed by a Do/While loop, which then checks the conditions.

A do/while loop can be used in many different ways, such as to process data or to handle a condition. It can also be used to repeat a block of code until some criteria are met.

Some examples of use cases for the do/ while statement are:

  • Executing commands until the specified variable has reached zero.
  • Executing commands until the specified file has been opened.
  • Executing commands until the specified amount of time has passed.

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download LearnVern App

App Preview Image
App QR Code Image
Code Scan or Download the app
Google Play Store
Apple App Store
598K+ Downloads
App Download Section Circle 1
4.57 Avg. Ratings
App Download Section Circle 2
15K+ Reviews
App Download Section Circle 3
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere