Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

int func2 (int x, int y, int z) { int calc=0; // ----------------> (2) calc=x*y*z; (*) return calc; } void func3 (double number) { double

int func2 (int x, int y, int z) { int calc=0; // ----------------> (2) calc=x*y*z; (*) return calc; } void func3 (double number) { double perc; // ----------------> (1) perc=number*3/10; (*) printf("Percentage: %lf",perc); } int main() { double result; int z = 10; void func1(int x, int y) { // ------------> (3) result = func2(x,y,z); (*) func3(result); (*) } // ----------------> (4) func1(2,4); return 0;

1. Considering the given C language 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 func1 (int x, int y) { int sum=0; double tmp; // ----------------> (2) sum=x+y; (*) tmp=func2(sum); (*) return tmp; } double func2 (int s) { double square; // ----------------> (1) square=s*s; (*) return square; } double func3(int a, int b) { int num; // ------------> (3) num = func1(a,b); (*) return num; } int main() { double result; // ----------------> (4) result = func3(5,3); printf("Result: %lf",result); return 0;

Considering the given C language code;a. Show the stack with all activation recordinstances, including static and dynamic chains,when execution reaches position 4, 3, 2 and 1in this order. You will be showing 4 separatestacks 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) forthe variables referenced at locations indicatedby (*)

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

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Discuss why human resources managers need to understand strategy.

Answered: 1 week ago

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago

Question

here) and other areas you consider relevant.

Answered: 1 week ago