Which statement executes a block only when a condition is true?

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 statement executes a block only when a condition is true?

Explanation:
Conditional execution is being tested here. An if statement runs its block only when the condition is true. It checks a boolean expression; if the result is true, the code inside executes, otherwise it’s skipped (you can add an else part to handle the false case). The other structures don’t fit this pattern: a for loop uses a condition to decide iteration count, not to decide a single block of code to run only when true; an output command just prints or displays something regardless of any condition; a case statement selects one of several blocks based on the value, not on a true/false test. So the if statement is the right choice.

Conditional execution is being tested here. An if statement runs its block only when the condition is true. It checks a boolean expression; if the result is true, the code inside executes, otherwise it’s skipped (you can add an else part to handle the false case). The other structures don’t fit this pattern: a for loop uses a condition to decide iteration count, not to decide a single block of code to run only when true; an output command just prints or displays something regardless of any condition; a case statement selects one of several blocks based on the value, not on a true/false test. So the if statement is the right choice.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy