Which construct selects one path from many based on the value of an expression?

Prepare for the IGCSE Algorithms and Pseudocode Exam. Study with comprehensive questions covering key algorithms and pseudocode techniques. Access hints and explanations to gear up for your exam success!

Multiple Choice

Which construct selects one path from many based on the value of an expression?

Explanation:
Selecting one path from many based on the value of an expression is accomplished by the case statement. It evaluates the expression and transfers control to the code block whose label matches the value, so only that path runs. If no label matches, a default block can run, which is useful for handling unexpected values. This is ideal when you have several discrete possibilities, like different menu choices. By contrast, an if statement tests boolean conditions to decide between branches, which can get unwieldy with many discrete options. A repeat until loop keeps executing until a condition is true, rather than choosing among several paths. An output command simply displays information and does not determine which block of code to execute.

Selecting one path from many based on the value of an expression is accomplished by the case statement. It evaluates the expression and transfers control to the code block whose label matches the value, so only that path runs. If no label matches, a default block can run, which is useful for handling unexpected values. This is ideal when you have several discrete possibilities, like different menu choices. By contrast, an if statement tests boolean conditions to decide between branches, which can get unwieldy with many discrete options. A repeat until loop keeps executing until a condition is true, rather than choosing among several paths. An output command simply displays information and does not determine which block of code to execute.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy