Bird
0
0

What will be the output of this script?

medium📝 Command Output Q5 of 15
Bash Scripting - Quoting and Expansion
What will be the output of this script?
#!/bin/bash
num=4
result=$((num ** 3))
echo $result
AError
B12
C81
D64
Step-by-Step Solution
Solution:
  1. Step 1: Understand exponentiation operator

    ** raises a number to the power of another.
  2. Step 2: Calculate 4 to the power 3

    4 * 4 * 4 = 64.
  3. Final Answer:

    64 -> Option D
  4. Quick Check:

    Exponentiation result = 64 [OK]
Quick Trick: Use ** for powers inside $(( )) [OK]
Common Mistakes:
MISTAKES
  • Using ^ instead of **
  • Expecting string concatenation
  • Syntax errors in arithmetic expansion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes