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

 int func2 (int x, int y, int z) { int calc=0;

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: %1f", perc); } int main() { double result; int z = 10; void funcl (int x, int y) { // ---------> (3) result = func2(x, y, z); (*) func3 (result); } (4) funci (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, funci, func2 and func3). C. Calculate the (chain_offset, local_offset) for the variables referenced at locations indicated by (*). *Write your answers on a A4 paper and hand it over to your lab assistant afterwards. double funci (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) 2. 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 (*). *Write your answers on a A4 paper and hand it over to your lab assistant afterwards. int num; // --> (3) num = funci (a,b); (*) return num; } int main() { double result; // ---> (4) result = func3 (5,3); printf("Result: %1f", result); return 0

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!