In the last two tutorials we talked about the for loop and the while loop.  Both of these require a condition to be met to run a set of statements.  In some circumstances you may want to run a statement at least once even if a condition is not met.  For those circumstances we can use a do while loop.  The do while runs through the statements once and then checks the condition.


/* Intro to do while loop
   Nathan Neil */
   #include <iostream>
   using namespace std;
   int main() {
   int x = 0;
   	cout << "Before Do\n";
     cout << "In Loop\n";
	cout << "We are out of the loop!";
   	return 0;


Pin It on Pinterest

Share This

Share this post with your friends!

%d bloggers like this: