Bird
0
0

Why do we use else in an if statement?

easy🧠 Conceptual Q2 of 15
Bash Scripting - Conditionals
Why do we use else in an if statement?
ATo run code only if the condition is true
BTo stop the script immediately
CTo repeat the condition multiple times
DTo run code when the condition is false
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of else

    else runs code when the if condition is false.
  2. Step 2: Match options to this purpose

    To run code when the condition is false correctly states this; others describe true condition, loops, or stopping script.
  3. Final Answer:

    To run code when the condition is false -> Option D
  4. Quick Check:

    else runs on false = D [OK]
Quick Trick: Else runs code if if-condition fails [OK]
Common Mistakes:
MISTAKES
  • Thinking else runs on true
  • Confusing else with loops
  • Using else to stop script

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes