Electrical and Computer Engineering
1 of 37
UAH
CPE 112
•ForStatement
•For (InitStatement Expression1; Expression2)
•     Statement
•
•Example
•for (lastNum = 1; lastNum <= 7; lastNum++)
•{
•   for (numtoPrint = 1; numtoPrint <= lastNum; numToPrint++)
•      cout << numToPrint;
•   cout << endl;
•}
•Note: The InitStatement can be the null statement and the two Expressions are optional.
The for Statement