This is one of your six Create Task points, rehearsed on somebody else's code. In May you will answer it about your own program, with only your Project Reference in front of you.
WRITTEN RESPONSE 2(a)
Identify the number of times the body of the iteration statement will execute.
AND describe a condition or error that would cause an infinite loop.Notice the word and. Both halves or nothing — a correct count with no infinite-loop answer scores the same as a blank page.
These are in exam notation on purpose. Your own program is in C#, but the exam's multiple-choice questions use the reference sheet, and counting is counting. If the notation slows you down, that is the thing to fix before May.
Paper only. Do not run these.
scores ← [88, 42, 95, 60, 71]
PROCEDURE countAbove(aList, limit){ found ← 0 i ← 1
REPEAT UNTIL(i > LENGTH(aList)) { IF(aList[i] > limit) { found ← found + 1 } i ← i + 1 }
RETURN(found)}
DISPLAY(countAbove(scores, 65))aList that makes the body execute zero times.PROCEDURE halve(n){ steps ← 0 left ← n
REPEAT UNTIL(left = 0) { steps ← steps + 1 left ← (left - (left MOD 2)) / 2 }
RETURN(steps)}halve(20), halve(7), halve(1), halve(0).left ← (left - (left MOD 2)) / 2 with left ← left / 2. The loop now runs forever. Explain precisely why — the answer is not "because it is wrong."PROCEDURE grid(n){ total ← 0 i ← 1
REPEAT UNTIL(i > n) { j ← 1
REPEAT UNTIL(j > n) { total ← total + 1 j ← j + 1 }
i ← i + 1 }
RETURN(total)}grid(3), grid(4), and grid(5)?grid(4)?j ← 1 so that it sits above the outer loop instead of inside it. What does grid(4) return now? Explain what happened.Find the first loop inside a procedure in your own program. Write out an answer to Written Response 2(a) about it — both halves, in full sentences.
If you cannot find a loop inside one of your own procedures, that is the most useful thing this page will tell you. You have sessions left to fix it.
All three problems answered, plus your own Written Response 2(a) in full sentences.
Worth 5 points, graded on completion.