Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SE309 Fall 2021-2022 Lab Work 10. 31 December 2021. Chapter 9-10. Goal: Subprograms, Parameter passing. (*) int func2 (int x, Int y, int z) int

image text in transcribed

SE309 Fall 2021-2022 Lab Work 10. 31 December 2021. Chapter 9-10. Goal: Subprograms, Parameter passing. (*) int func2 (int x, Int y, int z) int calc=0; // -> (2) calc-x*y*; return cale: 1 void func? (double number)! double pere: 77 --- -> (1) DOTCnumber 3/10; (*) printf("Percentage: 811",pere): 1 int main() { double result; int z = 10; void func1(int x; int y) { // - -> (3) result = func2(x, y, z); () func3 (result); (+) } -> (4) funci (2, 4); return 0; 1. Considering the given Clanguage code; a. Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 4, 3, 2 and 1 in this order. You will be showing 4 separate stacks corresponding to points 4,3,2,1. b. Find static depths for each subprogram (Main, func1, func2 and func3). c. Calculate the chain_offset, local_offset) the variables referenced at locations indicated by (*). double funcl (int x, int y){ int sum-0 double tmp: // -> (2) Sum=x+y: (*) tmpfunc2(sum); (*) return tmp: 2. Considering the given Clanguage code; a. Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 4, 3, 2 and 1 in this order. You will be showing 4 separate stacks corresponding to points 4,3,2,1. b. Find static depths for each subprogram (Main, func1, func2 and func3). c. Calculate the (chain_offset, local_offset) for the variables referenced at locations indicated by (*). double func2 (ints) double square; // ----> (1) square-2*2; (*) return square; } double func3(int a, int b) int num: // ---> (3) num - funci(a,b); (+1 return num; 1 int main() double result; ------> (4) result - func315,31; printf("Result: 1f", result); return 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions