QUESTION IMAGE
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
Response
Question 1
Brief Explanations
- An
if statementexecutes a block of code only when its condition is true. - A
break statementis for exiting loops/switch cases, not for conditional execution. - An
else statementcan't stand alone; it's paired withif. - A
for loopis for iteration, not conditional execution.
Brief Explanations
- An
if/else statementruns one block for a true condition and another for false. - An
if statementonly handles the true case (no default for false). - A
break statementexits loops/switch cases, not for dual - block conditional execution. - A
for loopis for iteration, not for this kind of conditional execution.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
A. if statement