Bird
0
0

What will be the output of this script if the user inputs: apple banana cherry date?

medium📝 Command Output Q13 of 15
Bash Scripting - User Input
What will be the output of this script if the user inputs: apple banana cherry date?
read a b c
 echo "$a"
 echo "$b"
 echo "$c"
Aapple banana cherry date
Bapple banana cherry
Capple banana cherry date
Dapple banana cherry date
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable assignment with extra words

    The first two variables a and b get the first two words: "apple" and "banana".
  2. Step 2: Assign leftover words to last variable

    The last variable c gets all remaining words combined: "cherry date".
  3. Final Answer:

    apple banana cherry date -> Option C
  4. Quick Check:

    Last variable holds leftover words [OK]
Quick Trick: Last variable collects all leftover input words [OK]
Common Mistakes:
MISTAKES
  • Expecting only one word in last variable
  • Assuming variables get input in reverse order
  • Confusing echo output formatting

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes