Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question tests your understanding of various parameter passing mechanisms. In each part, unless otherwise stated, you are given a subprogram definition and code fragment

image text in transcribed

This question tests your understanding of various parameter passing mechanisms. In each part, unless otherwise stated, you are given a subprogram definition and code fragment calling the subprogram in pseudocode written in a C-like syntax. (a) int weird(int x, int y) {return(x*y); What is the output of the following code fragment if (i) pass-by-value-result and (ii) pass-by-name is used for the function call? print weird(1 + 2, 3 + 4); Note the possibility that the output cannot be determined. Give detailed steps to explain how you obtain your output, perhaps with the aid of memory diagrams. (b) procedure fun (int m, int n) n = 1; n = m + n; What is the output of the following code fragment if (i) pass-by-value-result, (ii) pass-by-reference, and (iii) pass-by-name is used for the procedure call? i = 4; fun (j, i); print i; Note the possibility that the output cannot be determined. Give detailed steps to explain how you obtain your output, perhaps with the aid of memory diagrams

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started