The 'do while' Loop in C++

Published on: September 29, 2010

Today we learn the 'do while' loop in C++. It is an alternative to the "for" and "while" loops and it can work the same way as the other two loops or work very differently depending on how you use it. It is very convenient and it is my favorite loop in C++.

The video shows you how to use the do while loop with characters, strings, and your basic integer counter controlled loop. Everything you can do with the do while loop can also be done with the regular while loop but this is also very handy to do. The for loop however is best as a counter controlled loop so I wouldn't recommend you try anything else with it.

I hope you enjoy the video and if you have any requests feel free to let me know. Thanks for watching ! Thanks for watching and thanks for your supportand remember to subscribe!

Remember to checkout the Codesnip below to review the C++ code yourself! Feel free to copy the code, but I ask that you please provide credit if you leave the code unchanged when you use it.


//Programmer: Nazmus
//Program:  The Do While Loop

#include <iostream>
#include <string>
using namespace std;

int main()

 float yard, feet;
 int redo;


 cout << "Please input number of yards: "; 
 cin >> yard;

 feet = yard * 3;

 cout << yard << " yards equal to " << feet << " feet." << endl;

 while(feet != 3);