Question: Unix/Linux Questions Help Please Question 1: For the following script : for i in 3 4 do echo $i done 1. Make a function name

Unix/Linux Questions Help Please

Question 1: For the following script: for i in 3 4 do echo $i done 1. Make a function name Question1 (no space between Question and 1). 2. Make this example as in the body of this function. 3. Call this function twice. Note that calling the function twice does not mean you run the script twice. Answer

The script is:

The output and description is:

Question 2: a=2 b=3 echo "2 + 3 = $((a+b))" 1. Make a function named Question2 2. Copy this script in the body of the function. 3. Make the variable: a to be local. 4. Call the function. 5. After the call add the instruction: echo "2 + 3 = $((a+b))" 6. Run the program. 7. Why the second output is not correct? Answer

The script is:

The output and description is:

Question 3: p=1 for ((i=2; i <= 3; i++)) do p=$((p * i)) done echo "2 * 3 = $p" 1. Name the function Question3. 2. Remove the first line (that is: p=1) and write it before the definition of the function. 3. Except the first line (that is p=1) copy the rest of the lines into the body of the function. 4. Call the function twice. 5. Why the value of the variable p in the second line of the output is incorrect? Answer

The script is:

The output and description is:

Question 4: p=1 for ((i=2; i <= 3; i++)) do p=$((p * i)) done echo $p 1. Name the function Question4. 2. Copy the all the above lines into the body of the function. 3. Make the variable p to be local. 4. Replace the instruction: echo $p by an appropriate return instruction to return the value of the variable: p 5. Call the function. 6. After the call display the value of p. Answer

The script is:

The output and description is:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!