Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question: 1 what kind of statement allows us to run a block of code onl…

Question

question: 1
what kind of statement allows us to run a block of code only if a certain condition is true?
if statement
break statement
else statement
for loop

question: 2
what kind of statement allows us to run one block of code if one condition is true and a separate block of code otherwise?
if statement
break statement
if/else statement
for loop

Explanation:

Response
Question 1
Brief Explanations
  • An if statement executes a block of code only when its condition is true.
  • A break statement is for exiting loops/switch cases, not for conditional execution.
  • An else statement can't stand alone; it's paired with if.
  • A for loop is for iteration, not conditional execution.
Brief Explanations
  • An if/else statement runs one block for a true condition and another for false.
  • An if statement only handles the true case (no default for false).
  • A break statement exits loops/switch cases, not for dual - block conditional execution.
  • A for loop is for iteration, not for this kind of conditional execution.

Answer:

A. if statement

Question 2