|
for
Syntax:
for( initialization; test-condition; increment ) {
statement-list;
}
The for construct is a general looping mechanism consisting of 4 parts:
For example:
for( int i = 0; i < 10; i++ ) {
cout << "i is " << i << endl;
}
int j, k;
for( j = 0, k = 10;
j < k;
j++, k-- ) {
cout << "j is " << j << " and k is " << k << endl;
}
for( ; ; ) {
// loop forever!
}
|