Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1while (count <= 3) { ... } | AWrong - use a comparison operator, not = for assignment | |
| 2while (isRunning) { ... } | BInfinite loop | |
| 3Updates a variable so the loop eventually stops | Ccount = count + 1; | |
| 4Runs forever because the condition never becomes false | DWrong - the condition needs parentheses | |
| 5while n > 0 { n = n - 1; } | ERepeats the block while isRunning stays true | |
| 6while (z = 3) { z = z + 1; } | FRepeats the block while count is 3 or less |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
while — Repeats a block of code as long as its condition inside parentheses stays true.while (count <= 3) {while (count <= 3) {while (n > 0) {
n = n - 1;
}while (isRunning) {while (i < 5) {
i = i + 1;
}