Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A flowchart inputs two numbers, A and B. A decision asks A > B?. Yes leads to OUTPUT A. No leads to OUTPUT B. Both then go to 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. is false, so the No path outputs B, which is .
Step 2. is false, so the output is B, which is . Both numbers are , so the output is still right.
Step 3. Purpose. It inputs two numbers and outputs the larger one. If they are equal it outputs that value.
Answer: (a) , (b) .
The pseudocode is:
INPUT A
INPUT B
IF A > B
THEN
OUTPUT A
ELSE
OUTPUT B
ENDIFLog in to join the discussion.
Loading…