Bird
0
0

Given the Bash array declaration numbers=(10 20 30 40), what is the output of echo ${numbers[3]}?

medium📝 Command Output Q13 of 15
Bash Scripting - Arrays
Given the Bash array declaration numbers=(10 20 30 40), what is the output of echo ${numbers[3]}?
A40
B10
C30
DError
Step-by-Step Solution
Solution:
  1. Step 1: Identify the element at index 3

    Array numbers has elements: index 0=10, 1=20, 2=30, 3=40.
  2. Step 2: Access element at index 3

    ${numbers[3]} returns the element at index 3, which is 40.
  3. Final Answer:

    40 -> Option A
  4. Quick Check:

    numbers[3] = 40 [OK]
Quick Trick: Index 3 means fourth element, here 40 [OK]
Common Mistakes:
MISTAKES
  • Confusing index 3 with value 30
  • Expecting error for valid index
  • Using 1-based indexing
  • Printing entire array instead of element

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes