text: A echoes any text the
  user introduces until the user enters goodbye:
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  12
  13
  14
  // echo machine
  #include <iostream>
  #include <string>
  using namespace std;
  int main ()
  {
  string str;
  do {
  cout << "Enter text: ";
  getline (cin,str);
  cout << "You entered: " << str << '\n';
  } while (str != "goodbye");
  }
  Enter text: hello
  You entered: hello
  Enter text: who's there?
  You entered: who's there?
  Enter text: goodbye
  You entered: ascondition.
  It works in the following way:
  1. initialization is executed. Generally, this declares a counter variable, and sets it to
  some initial value. This is executed a single time, at the beginning of the loop.
  2. condition is checked. If it is true, the loop continues; otherwise, the loop ends,
  and statement is skipped, going directly to step 5.
  3. statement is executed. As usual, it can be either a single statement or a block enclosed
  in curly braces { }.
  4. increase is executed, and the loop gets back to step 2.
  5. the loop ends: execution continues by the next statement after it.
  Here is the countdown example using a for loop:
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  // countdown using a for loop
  #include <iostream>
  using namespace std;
  int main ()
  {
  for (int n=10; n>0; n--) {
  cout << n << ", ";
  }
  cout << "liftoff!\n";
  }
  10, 9, 8, 7, 6, 5, 4, 3, 2, 1, liftoff!:
  1
  2
  3
  4
  for ( n=0, i=100 ; n!=i ; ++n, --i )
  {
  // whatever here...
  }.