The For Loop

We write code like this :
   int i;

   i = startvalue
   while (test_involving i) {
      statements
      change_the_value_of_i
   }
that they have implemented another control structure. The structure is called a for loop.
   for (initialization; condition; increment) {
      statements
   }
It performs exactly as the above loop.
  1. The initialization statement is performed
  2. The condition is checked, if it is false, we exit the loop
  3. Otherwise we execute the statemtnts
  4. We execute the increment
  5. We go back to step two.
For example, to count from 1 to 10
   int i;

   i = 1;
   while (i <= 10) {
      cout << " I is " << i << endl;
      i++;
   }

   or 

   for (i=1;i<=10;i++) {
      cout << " I is " << i << endl;
   }
How about this code

// assume menu returns a choice a-d
char ch;

ch = menu()
while(('a' <= ch ) && (ch <= 'd') ) {
   ch = menu();
}

for(ch=menu(); ('a' <= ch ) && (ch <= 'd'); ch=menu()) ;