Key for Homework 3 on Iteration Q A Reason ----------------------------------------------------------------------------------- 1 4 The while loop continues until (loopCount <= 145) is false. Since loopCount is initialized to 1, and increased by 1 on each pass through the while loop, loopCount will be 146 when the loop terminates. 2 2 someInt is initialized to 273, and the loop condition (someInt > 500) is false so the loop body is never executed. 3 5 The loop will terminate when (Beta >= 0 && Beta < 10) is false. That is, when either Beta < 0 or Beta >= 10. 4 5 The while loop increments n before printing it. 5 3 The body of the while loop is just the cout statement since there are NO curly braces. Since the increment statement is not in the loop body, the loop will never terminate and n will never change from its initial value. 6 3 The loop control variable is loopCount (since that's the variable whose value is tested in the loop condition). 7 2 The loop must stop after the value 10 is printed, so N will equal 10 at the end of that pass. The test must STOP the loop at that point, so answer 1 doesn't do it. 8 1 The loop test (loopCount > 3) is initially false, so the body of the loop is never executed. 9 7 The given while loop sums the integers -5 through 15, inclusive. Loop 1 does the same thing, obviously. Loop 2 increments count an extra time on each pass through the loop. Loop 3 is the same as loop 1 except for the location of the initialiation of sum. Loop 4 sums the integers 1 through 21, which will not produce the same answer. 10 2 Trace it. It's straightforward, since the inner loop will always leave n equaling 8.