The do loop

This loop prints 1 to 12. Notice that the test is at the end.

1
2
3
4
5
6
7
8
9
10
11
12
// Uses do loop to count from 1 to 12
#include <iostream>
using namespace std;
void main()
{ int num=1; //num is given an initial value
  do {
    cout<<num<<"\n";
    num++;
  } while (num<=12);
  cout<<"The end\n";
 system("pause");
} //main
CODE

NEXT: Using a do loop to force a valid response