Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ans by no plz tnx I. What is the output from the (unedited) C program below? 5 points. f: a= ______ b= ______ c= ______

ans by no plz tnx
image text in transcribed

I. What is the output from the (unedited) C program below?5 points.

f: a=______ b=______ c=______

g: a=______ b=______ c=______

main: a=______ b=______ c=______

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: a=______ b=______ c=______

g: a=______ b=______ c=______

main: a=______ b=______ c=______

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: a=______ b=______ c=______

g: a=______ b=______ c=______

main: a=______ b=______ c=______

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.

code in text

#include

int a = 10;

int b = 20;

int c = 30;

astatic void f(void) {

a += 5; b += 5;

+= 5;

printf ("f: a=8d b=8d c=8d ", a, b, c);

L)

astatic void g(void) (

int c = 40;

b += 5;

+= 5;

f();

printf("g: a=8d b=8d c=8dln", a, b, c);

aint main (int arg, char *argv []) (

g();

printE("main: a=8d b=8d c=8dln", a, b, c);

image text in transcribed
1. What is the output from the (unedited) C program below? 5 points. f:a=b=c=g:a=b=c=main:a=b=ccm 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:a=g:a=main:a= III. Modify the C program to emulate dynamic scope. Follow these steps. 10 points. 1. Move lines 3-5 into main0. 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 g0 into fO. 4. Do some additional changes to make gec happy. Make sure you use the -Wall option on gec. 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:a===c=g:a=b=main:a= 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

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

Students also viewed these Databases questions

Question

Do you have any future plans for marriage and children?

Answered: 1 week ago

Question

10-9 How have social technologies changed e-commerce?

Answered: 1 week ago