Computer Program Reading Comprehension Project
U of T Computer Program Reading Comprehension Project
A Slightly Different For-Loop
The for-loop on this page is just a little different from the basic for-loop. These differences appear fairly often, but they are not very noticable. We repeat some of the questions asked about the basic for-loop in order to sensitize you to the impact of these small variations.

Download files: ASlightlyDifferentForLoop.java
Areas: Introduction to loops.


ASlightlyDifferentForLoop.java
1for (int i = 1; i <= 30; i++)
2    {
3    System.out.println (i);
4    }


Question 1
What is the test of the loop?
Solution

Question 2
What is the starting value of the loop counter?
Solution

Question 3
What is the value of the loop counter the last time the loop is executed?
Solution

Question 4
What does the loop do?
Solution

Question 5
What is the value of the loop counter the last time it is tested?
Solution

Question 6
How many times will the body of the loop be executed?
Solution

Question 7
How many times will the test be evaluated?
Solution

Question 8
How many times will the loop counter be incremented?
Solution

Question 9
Which parts of this code can cause the loop to exit?
Solution

Question 10
Under what conditions will this loop exit?
Solution