Bird
0
0

What does the command declare -i num=5 do in a bash script?

easy🧠 Conceptual Q11 of 15
Bash Scripting - Variables
What does the command declare -i num=5 do in a bash script?
AIt creates an integer variable named num with value 5.
BIt creates a string variable named num with value '5'.
CIt declares a function named num that returns 5.
DIt prints the number 5 to the terminal.
Step-by-Step Solution
Solution:
  1. Step 1: Understand declare -i usage

    The declare -i command in bash makes a variable hold integer values only.
  2. Step 2: Analyze the assignment

    Here, num is assigned the integer value 5, so it becomes an integer variable.
  3. Final Answer:

    It creates an integer variable named num with value 5. -> Option A
  4. Quick Check:

    declare -i num=5 means integer variable num = 5 [OK]
Quick Trick: declare -i means integer variable assignment [OK]
Common Mistakes:
MISTAKES
  • Thinking declare -i creates a string variable
  • Confusing declare -i with printing output
  • Assuming declare -i creates a function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes