What does this algorithm output?
count ← 0FOR i ← 3 TO 15 STEP 4count ← count + 1ENDFOROUTPUT count
AQA 3.2.2 · Programming
AQA 8525 questions. AQA · OCR · The lesson
What does this algorithm output?
count ← 0FOR i ← 3 TO 15 STEP 4count ← count + 1ENDFOROUTPUT count
A program asks for a password until the user types the right one. Which kind of loop fits best?
What does this algorithm output?
n ← 10REPEATn ← n + 5UNTIL n > 8OUTPUT n
What does this algorithm output?
total ← 0x ← 12WHILE x < 10total ← total + xx ← x + 1ENDWHILEOUTPUT total
What does this algorithm output?
stars ← 0FOR row ← 1 TO 3FOR col ← 1 TO rowstars ← stars + 1ENDFORENDFOROUTPUT stars
The algorithm adds square numbers until the total reaches 20 or more.
total ← 0n ← 1WHILE total < 20total ← total + n * nn ← n + 1ENDWHILEOUTPUT n
the trace table. Write a value only when it changes; the first row is done for you.
| total | n | Output |
|---|---|---|
| 0 | 1 | |
how many times the loop body runs.
why a condition-controlled loop is used here rather than a count-controlled loop.
A program must ask the user for ten whole numbers, one at a time, and output the total of the numbers that are greater than 0.
the program. You may use pseudo-code or a high-level language such as Python.