Sharpen your skills in translating between flowcharts and pseudocode with these medium-level conversion questions. This quiz covers flowchart interpretation, pseudocode structure, and common logic patterns to strengthen understanding for programming and algorithm design.
When converting the flowchart segment 'Start → Input X → Output X + 2 → End' into pseudocode, which of the following is the clearest equivalent?
Explanation: The correct answer matches the process in the flowchart: reading a value, then outputting that value plus two. Options B and D either multiply or incorrectly order the input and output steps, while C combines steps and labels in a confusing order. The original flowchart sequence is preserved best in the first option.
Given the pseudocode: If age u003E= 18 then Output 'Adult' else Output 'Minor' endif, which flowchart symbol should be used for the decision-making step?
Explanation: The diamond is the standard symbol for decision or conditional operations in flowcharts. Rectangles are used for processes, parallelograms for input/output, and ovals for start or end points. Only the diamond accurately represents a branching logical condition in this scenario.
How should a flowchart with a loop labeled 'Repeat Input number until number u003E 10' be written in pseudocode?
Explanation: The correct option directly mirrors the loop logic from the flowchart, indicating repetition based on a condition. Option B describes a for loop, which is inappropriate here. Option C reverses the condition, and D uses a conditional, not a loop. Only the first maintains the correct repetition until the specified condition.
In converting pseudocode keywords 'Begin' and 'End' to flowchart symbols, which shapes should be used for both?
Explanation: Ovals are universally used to represent Start and End (or Begin and End) points in flowcharts. Rectangles represent process steps, diamonds are for decisions, and hexagons are not standard for these actions. The selection of ovals ensures clear, widely-accepted flowchart structure.
If a flowchart shows two input steps (Input Name and Input Age) happening independently before merging, which pseudocode best reflects this sequence?
Explanation: The best pseudocode representation is a sequence of independent input commands, as in 'Read Name; Read Age;'. The second and fourth options imply strict sequencing with 'then' or 'followed by', while the third mixes the variables irrationally. Only the first option fits the parallel and then merged design of the original flowchart.