Although For statements are used most frequently for count-controlled loops, C++ allows you to write any While loop by using a For statement. To use For loops intelligently, you should know the following facts.
1. In the syntax template, InitStatement can be the null statement, and Expression2 is optional. If Expression2 is omitted, there is no statement for the compiler to insert at the bottom of the loop. As a result, you could write the While loop
while (inputVal != 999)
cin >> inputVal;
as the equivalent For loop
for ( ; inputVal != 999; )
cin >> inputVal;
2. According to the syntax template, Expression1the While conditionis optional. If you omit it, the expression 1 (meaning TRUE) is assumed.