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 perc;

image text in transcribed

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

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions