Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A flowchart works like this. Start. Set Big to and Loops to . Input X. Decision: is X > 10? If Yes, add to Big. Then add to Loops. Decision: is Loops = 5? If No, go back to the input. If Yes, output Big and stop.
Flowchart symbols: terminator (START, STOP), process (rectangle), input/output (parallelogram), decision (diamond, two exits Yes and No), subroutine (rectangle with a line inside each end), flow line (arrow). A flow line back to an earlier shape makes a loop. Conditions are written precisely, such as Count > 10.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Step 1. Inputs (a). : yes. : no. : yes. : no. : yes. So Big is .
Step 2. Inputs (b). : yes. : yes. : no. : no. : no. So Big is .
Step 3. The purpose. It inputs five numbers and outputs how many of them are greater than .
Answer: (a) , (b) .
Here is the same algorithm in pseudocode.
Big ← 0
Loops ← 0
REPEAT
INPUT X
IF X > 10
THEN
Big ← Big + 1
ENDIF
Loops ← Loops + 1
UNTIL Loops = 5
OUTPUT BigWatch out. is not greater than . A value equal to the number in the decision is the one most often counted by mistake.
Log in to join the discussion.
Loading…