exam questions

Exam LX0-104 All Questions

View all questions & answers for the LX0-104 exam

Exam LX0-104 topic 1 question 10 discussion

Actual exam question from CompTIA's LX0-104
Question #: 10
Topic #: 1
[All LX0-104 Questions]

Which of the following commands creates a function in Bash that outputs the sum of two numbers?

  • A. function sumitup { echo $(($1 + $2)) ; }
  • B. command sumitup { echo $(($1 + $2)) ; }
  • C. function sumitup { echo $1 + $2 ; }
  • D. method sumitup { echo $1 + $2 ; }
  • E. command sumitup { echo $1 + $2 ; }
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
linux_admin
2 years, 2 months ago
A. function sumitup { echo $(($1 + $2)) ; } The function sumitup is a user-defined function in the Bash shell. It takes two arguments, represented by the variables $1 and $2. These arguments can be passed to the function when it is called. The function performs a calculation that adds the two arguments together and the result is stored in the $(($1 + $2)) expression. The echo command then outputs the result of this expression. The keyword function is used to define a function, followed by the function name sumitup. The commands that the function will perform are enclosed in curly braces {} and separated by semicolons ;. In this example, the function only has one command, which is echo $(($1 + $2)). This function can be called by simply typing sumitup followed by the two numbers that should be added. For example, sumitup 4 5 will output 9.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago