Quiz 18 Solution - Monday July 10, 2000
1. What is the syntax of a for loop?
for (statement1;condition;statement2) { somestatements; }
2. What are the parts of the header of the for loop usually used for?
statement1 is usually used as an initialization
statement2 is usually used as an increment or a decrement
condition determines under what condition the body of the for loop and statement 2 will execute
3. If counter=1, and a = ++counter, what is the value of a?
2
4. If we have the statements counter=1; and b = counter++; in a program, what will be the value of counter after the second statement is executed?
2