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

Study for the IGCSE Algorithms and Pseudocode exam to demonstrate mastery of computing foundations. Enhance learning with quizzes, in-depth explanations, and custom study plans. Begin your journey to success now!

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