Question: II. Assume that C has dynamic scope (it does not) instead of static scope. What would the output be? (Do this before doing part III,

 II. Assume that C has dynamic scope (it does not) insteadof static scope. What would the output be? (Do this before doing

II. Assume that C has dynamic scope (it does not) instead of static scope. What would the output be? (Do this before doing part III, but you can change your answers after doing part III). 5 points. f: as b= cs g: a= ce b= main: a III. Modify the C program to emulate dynamic scope. Follow these steps. 10 points. 1. Move lines 3-5 into main(). Do not leave any global variables. 2. Since g() references a and b but does not define them, pass them in from main(). BUT you cannot just pass the values of a and b. You must pass the addresses of a and b. 3. Likewise, f() references a, b, c so you need to pass addresses, from g() into f(). 4. Do some additional changes to make gcc happy. Make sure you use the-Wall option on gcc. 5. Verify that you got the same answers as part II above. Or update part II to match. IV. What is the output from your modified C program? It should match part II above. 10 points. f: ar b= g: as b= main: a b= Submit your modified C program, as well as the outputs for parts I, II and IV. You can submit the output as a text file, you can update this word doc, you can submit a pdf, etc. #include scope.c 1 2 3 4 5 6 int a = 10; int b = 20; int c = 30; 7 static void f(void) { a += 5; b += 5; C += 5; 11 printf("f: a=%d b=8d c=&d ", a, b, c); 12 } 14 Estatic void g(void) { 15 int c = 40; 16 b += 5; 17 C += 5; 18 f(); 19 printf("g: a=&d b=$d c=8d ", a, b, c); 20 } 21 22 pint main(int arge, char *argv[]) { 23 g(); 24 printf ("main: a=&d b=%d c=%d ", a, b, c); 25

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!