The 'while' loop in C++

Published on: August 18, 2010

Today we learn the "while" loop in c++. I've already shown you how the "for" loop works and the "while" loop is just as good once you get used to it. I break it down a little and explain how it fully works. I've heard from some that the while loop is actually easier but I'll let you judge for yourself.

I hope you enjoy the video and if you have any requests feel free to let me know.

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.

Codesnip:

//Programmer: Nazmus
//Program:  The While Loop
//Purpose:  To learn the "while" loop
//Website:  EasyProgramming.net

#include <iostream>
using namespace std;

int main()
{
 int count, i;
 count = 0;
 i = 5;

 while(i<10){
 count = count + i;
 i++;

 cout << "Count is " << count << '.' << endl;
 }
 system("pause");
}



Comments: