Exam LFCS All QuestionsBrowse all questions from this exam
Question 115

After issuing:

function myfunction { echo $1 $2 ; }

in Bash, which output does:

myfunction A B C

Produce?

    Correct Answer: A

    In the given Bash function 'myfunction', the parameters $1 and $2 refer to the first and second arguments passed to the function, respectively. When 'myfunction A B C' is called, 'A' is assigned to $1 and 'B' is assigned to $2. The third argument 'C' is ignored because the function only echoes the first two arguments. Therefore, the output is 'A B'.

Discussion
EliteAllenOption: A

$ function myfunction { echo $1 $2 ; } $ myfunction A B C A B