For Loops

In this example, ch is a char (character) starts with 'a' and continues to print up to 'z'.

1
2
3
4
5
6
7
8
9
10
11
12
//for loop prints the alphabet 
#include <iostream>
using namespace std;
int main() { 
  char ch; //used to 'drive' the loop
  for (ch = 'a'; ch<='z'; ch++) { 
    cout<<ch;
  } //for loop
  cout<<endl;
  system("pause");
  return 0;
} //main
CODE
Output:
abcdefghijklmnopqrstuvwxyz
Press any key to continue . . .

Can you print the alphabet backwards?

NEXT: Count by .5 with 2 assignments and increments