Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 (15 marks) (a) (10 marks) The following programming model contains in its code memory the indicated C program composed of 2 functions. You

image text in transcribedimage text in transcribedimage text in transcribed

Question 1 (15 marks) (a) (10 marks) The following programming model contains in its code memory the indicated C program composed of 2 functions. You will be showing how the working memory is used during the execution of the two functions. Each piece of working memory is associated to a function using a pair of lines. (Note: the first pair of lines associates the piece of working memory allocated to the function main and the second pair of lines associates the piece allocated to the function compute_weight). Show how the given C program affects the contents of the working memory: Show how the structure is organized in the working memory for each function. Show the values are assigned to the members of the structure. Be sure to show all values that are assigned and replaced. Record successive assignments to variables/parameters as follows: variable name 2.6., 10 Show the values are assigned to the members of the structure. Be sure to show all values that are assigned and replaced. Record successive assignments to structure members as follows: Name of structure variable Name of member 1 2 2,6,A, 10 Name of member 222,6, 4 Using arrows show how values are copied between the working memory allocated to the function main and the working memory allocated to the function compute _weight. For copying the contents of a structure variable, you need only used a single arrow. In the console window show the output of the program (b) (5 marks) The following programming model contains in its code memory the indicated C program composed of a single function, main. You will be showing how the working memory is used during the execution of main. Show how the given C program affects the contents of the working memory: Show the values are assigned to the variables and array elements. Be sure to show all values that are assigned and replaced. Record successive assignments to variables/parameters as follows \ 2.6. 10 Vartble name Code Memory Working Memory #include void main) double arr[8-1.2, 8.5, 3.7, -11.2 double w int index; 8.3 index7 arr [4]-9.3: arr [index] arr[6-(arr[2arr [index-3])/arr [1) arr [5] -arr[index-41 CPU Code Memory Working Memory include include cmath.h Structure type definition cylinder container typedef struct double density. // Container density (kg/w") double thickness: IThickness of container walls ( double dianeter: Dianeter of container (m) double height: / Height of container n) CYL CONTAINER Punction Prototype double coapute veight (CYL CONTAINER) void nain) Declaration of variables CYL CONTATNER cy1- 2830.0, 0.33, 0.5, 1.1 double weight veight compute veight (cyl): data Display results printf( Container datain printr"Densit printf (Thickness: 80.3f cnin, cyl.thickness) printf 0.21f kg/m 3n", cy1.density) Dianeter: 0.3f mn", cyl.dianeter) Height: 80.3f in, cl. height) printf("The weight of the container is 80.3f gin double compute veight (CYL CONTAIR ylinder) // Declaration of the variable double weight i weight of the container II Computation vith accunulation weight M PI cylinder.dianeter cylinder.diameter/2.0: Area of 2 end weight- veight M PI*cylinder dianeter clinder.height: Area of s veight-weight cylinder. thickness/100.0 I The volume veight-veight cylinder. density: The weight return (weight) Console Container data Density: 2830.00 kg/m 3 Thickness: 0.350 cm Diameter: 0.500m Height: 1.100 m The weight of the container is 21.004 kg CPU Note: You do NOT need to show how the CPU interacts with memory

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

2. Define communication.

Answered: 1 week ago