post
poster: Comrade-Sergei
description: While Loop Demo
language: C++
[download]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    //Input the loop count
    int loopCount;
    cout << "Enter the amount of loops you would like to perform: ";
    cin >> loopCount;
    
    //Now loop that many times
    while (loopCount > 0)
    {
          loopCount = loopCount - 1;
          cout << "Only " << loopCount << " loops remaining!\n";
    }
    
    //Wait until user is readt to quit. 
    
    system("PAUSE");
    return EXIT_SUCCESS;
}