Question

LILLLL Divesh Balamurugan Procedures and Parameters (Level 3) Mar 27, 4:11:21 PM Determine what is printed by the following c
0 0
Add a comment Improve this question Transcribed image text
Answer #1

This is a simple algorithm of calling functions or methods.

The answer will be -12. How? Let's see.

In any algorithm of calling functions firstly, we should see from where the function is being called.

In the above algorithm Line-11 is calling the function F.

And, while returning the result it is calling the function G.

So first we will see Line 11.

1. ans <-- -3*F(4,2)

The function F is called with parameters 4 and 2. Then the result of this function will be multiplied with -3 for the answer.

2. In Line 1,

Procedure F(x,y)

The function F has 2 values x=4 and y=2. These are the values that we passed in the parameters while calling Function F in line 11.

3. The return statement in function F calls another function G with the same parameters.

In function G,

Return x-y

means it will return the difference of x and y where x=4 and y=2 as passed in parameters.

So 4-2=2. It will return 2 to the function F.

4. Now we will get back to Function F return statement

Return 2*G(x,y)

and G(x,y)=2 that we just solved.

So, 2*2=4 which will be returned to Line 11.

5. Coming back to Line 11

-3*4=-12 which will be allocated to ans

In Line 12 it displays the ans which is -12.

Add a comment
Know the answer?
Add Answer to:
LILLLL Divesh Balamurugan Procedures and Parameters (Level 3) Mar 27, 4:11:21 PM Determine what is printed...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 21-3 Sound Intensity Mar 30 at 11:59 Level Due this Frida pm (EDT) At a distance...

    21-3 Sound Intensity Mar 30 at 11:59 Level Due this Frida pm (EDT) At a distance of 4.75 m from a localized sound source, you measure the intensity level as 73.0 dB. How far away from the source must you be for the intensity level to fall to 50.5 dB? Submit AnswerTries 0/15 Post Discussion Send Feedback

  • Wed 6-27 PM practice final summer 2020.pdf (page 3 of 11) Resistors R3 and R4 2)...

    Wed 6-27 PM practice final summer 2020.pdf (page 3 of 11) Resistors R3 and R4 2) Determine the Unknown when R3= 1 R4 5 Soo LOO 32003 R4 30V 250 FEKT 1120mA 100 CAS * ww - 2 $ 4 3 5 6 & 7 B -0 I! W E R т C Y - o P S D F G HJ K L V C V Z B B M * command

  • Please answer and explain thank you. Question 1 What will be printed when the following code...

    Please answer and explain thank you. Question 1 What will be printed when the following code is executed? double x = 45678.259; System.out.printf("%,.2f", x); Group of answer choices 45678.259 0,045,678.26 45,678.26 45,678.3 Question 2 What will be printed when the following code is executed? double x = 45678.259; String output = String.format("%,.1f", x); System.out.println(output); Group of answer choices 45678.259 45,678.259 45,678.26 45,678.3 Question 3 What will be the value of ans after the following code has been executed? int ans=0;...

  • Due Monday, Mar 30, 11:59pm CDT Determine the cardinal number of a union of two finite...

    Due Monday, Mar 30, 11:59pm CDT Determine the cardinal number of a union of two finite sets Question If n(A) = 14, n(B) = 51, and n( A B) = 12, then what is n(AUB) Provide your answer below: Previous 4 5 6 7 8 9 0 R. I Y U 1 0 F F G H I

  • submissions until Sunday, September 27, 2020 at 11:59 pm Question 4 (1 point) Refer to the...

    submissions until Sunday, September 27, 2020 at 11:59 pm Question 4 (1 point) Refer to the following chart showing a distribution of exporting firms: Exports (5 millions) Number of Firms $2 to under 55 6 5 to under 8 13 8 to under 11 20 11 to under 14 10 14 to under 17 3 For the distribution above. what is the midpoint of the class with the greatest frequency? D Co search o E F1 F2 F3 F4 F5...

  • For the given program determine what is printed after each write statement assuming static scoping, deep...

    For the given program determine what is printed after each write statement assuming static scoping, deep binding and parameters are passed-by-value-result. program main;    var X: integer;    procedure Q(var I: integer; function R(J: integer):integer);             var X: integer;             begin              X:=4;              write(“In Q, before call of R, I=”, I, “X=”, X);              I=R(I);              write(“In Q, after call of R, I=”, I, “X=”, X);           end;        procedure P;            var I: integer;           ...

  • Using tables 8-5 and 6-6 in your textbook, determine the sample size for each of the control proc...

    Using tables 8-5 and 6-6 in your textbook, determine the sample size for each of the control procedures shown in the following table (assuming a very large population): Control Procedure #3 10% 7% 3% #4 10% 8% 4% #2 #1 5 % 4% 1% Parameters Risk of incorrect acceptance Tolerable deviation rate Expected population deviation rate 5% 2% Sample sizes: Control Procedure1 Control Procedure 2 Control Procedure 3 Control Procedure 4 Using tables 8-5 and 6-6 in your textbook, determine...

  • Problem 4 (7 points): What is the output (printed to command prompt) of the following code...

    Problem 4 (7 points): What is the output (printed to command prompt) of the following code (Exam2Prob4.m)? DO NOT USE MATLAB for solving this problem. ZERO CREDIT if all steps are not shown. You should explain the output of each code as if you are executing the code. (answer 2 points; process, with each step - 8 points) Exam2 Prob4.m clc; clear; close all; p=4; q = 3; r5; (x, y] = user Defined (p, q, r); fprintf('x- $d, y=%d',x,y);...

  • Mars Assignment Procedures Consider the ordering of the nibbles in a word as shown below Write pr...

    Mars Assignment Procedures Consider the ordering of the nibbles in a word as shown below Write procedures to do the following A procedure named getNibble that has two parameters $a0 is a word value and $a1 is a nibble number (per the diagram above). This procedure should return in $v0 the nibble in Sa0 selected by Sa1. The retrieved nibble should be placed in nibble 0 of Svo 1) A procedure named putNibble that has two parameters $a0 is a...

  • 1) The domain of g(x) (7x-21) is ) -21 bx -3C 23 d) 27 2) For...

    1) The domain of g(x) (7x-21) is ) -21 bx -3C 23 d) 27 2) For x # 6 and f, then fCx) a) x2 12x +36 b)x-6 )x2-36 x2-12x+36 x-6x+6 d) x-6 3) If A4xs B4xs then AB is of type a) 4 x 4 b) 3 x 8 d) Can't be found. c) 3 x 4 4 -2 4) a) 60 b) 51 c) 12 d) 26 5) In the General Simplex Method, a surplus variable is c)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT