1. What is the output from the (unedited) C program below? 5 points. f: a-15 b-30...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. What is the output from the (unedited) C program below? 5 points. f: a-15 b-30 c-35 g: a-15 b-30 c-45 main: a-15 b-30 c-35 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= g: a- b= main: a- III. Modify the C program to emulate dynamic scope. Follow these steps. 10 points. Move lines 3-5 into main(). Do not leave any global variables. 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. Likewise, f() references a, b, c so you need to pass addresses, from g() into f(). 3. 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. 1. 2. IV. What is the output from your modified C program? It should match part II above. 10 points. f: a- g: a- 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. b= b= 1. What is the output from the (unedited) C program below? 5 points. f: a-15 b-30 c-35 g: a-15 b-30 c-45 main: a-15 b-30 c-35 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= g: a- b= main: a- III. Modify the C program to emulate dynamic scope. Follow these steps. 10 points. Move lines 3-5 into main(). Do not leave any global variables. 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. Likewise, f() references a, b, c so you need to pass addresses, from g() into f(). 3. 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. 1. 2. IV. What is the output from your modified C program? It should match part II above. 10 points. f: a- g: a- 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. b= b=
Expert Answer:
Answer rating: 100% (QA)
Part I The output of the unedited C program is as follows f a15 b30 c35 g a15 b30 c45 main a15 b30 c35 Explanation This is because C uses static scopi... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
What is your approach to problem-solving? Give an example of where your approach has been effective. Would you like to change some parts of your approach?
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
A utilization greater than one suggests that the mean service time is higher than the mean inter-arrival time. True False QUESTION 3 It costs five times more money to retain a current customer than...
-
The beam will fail when the maximum shear force is Vmax or the maximum bending moment is Mmax. Determine the magnitude M0 of the largest couple moments it will support. Units Used: kN = 103 N Given:...
-
Year Cash Flow 0 -$200 1 50 2 60 3 70 4 200 Given the above cashflows of a project, calculate its payback, discounted payback, IRR, NPV, profitability index. Assume the discount rate is 9%. Show your...
-
Consider the National Football League data in Table B.1. Build a linear regression model relating the number of games won to the yards gained rushing by opponents $x_{8}$, the percentage of rushing...
-
You have a choice of borrowing money from a finance company at 24 percent compounded monthly or borrowing money from a bank at 26 percent compounded annually. Which alternative is the most attractive?
-
You have an outstanding student loan with required payments of $550 per month for the next four years. The interest rate on the loan is 11% APR (compounded monthly). Now that you realize your best...
-
The following information is for Montreal Gloves Inc. for the year 2020: Manufacturing costs Number of gloves manufactured Beginning inventory $ 3,016,700 311,000 pairs 0 pairs Sales in 2020 were...
-
Two long straight wires pierce the plane of the paper at vertices of an equilateral triangle as shown below. They each carry 2 A. out of the paper. The magnetic field at the third vertex (P) has...
-
What is a range forward contract?
-
Packaging equipment for Xi Cling Wrap is expected to result in end-of-year net savings of \($23\),000 per year for 3 years. The equipment can be purchased for \($60\),000 and will have a market value...
-
Use the Internet to access Home Depot's most recent annual report. a. What evidence did you find that Home Depot continues to rely on present worth analysis in its corporate decision making? b. Does...
-
Explain how a \(5 \times 8\) option contract on electricity with daily exercise works. Explain how a \(5 \times 8\) option contract on electricity with monthly exercise works. Which is worth more?
-
Compute the impulse response of the system with transfer function \[H(z)=\frac{z^{2}}{4 z^{2}-2 \sqrt{2} z+1}\] supposing that the system is stable.
-
What control character signals the end of input with the EOF signal? Ctrl-A Ctrl-E Ctrl-C Ctrl-B Ctrl-D
-
In the busy port of Chennai, India, the number of containers loaded onto ships during a 15-week period is as follows: 1. Develop a linear trend equation to forecast container loadings. 2. Using the...
-
Diego, age 28, married Dolores, age 27, in 2012. Their salaries for the year amounted to $46,479 and they had interest income of $3,500. Diego and Dolores' deductions for adjusted gross income...
-
Robert Ramos (age 36) is a single taxpayer, living at 8765 Bay Dr., Monterey, CA 93940. His Social Security number is 976-23-5132. Robert's earnings and income tax withholding as the manager of a...
-
In 2012, Lou has a salary of $54,000 from her job. She also has interest income of $1,700. Lou is single and has no dependents. During the year, Lou sold silver coins held as an investment for a...
-
Calculate the volatility and the current price of oil futures implied by the call 1600 August and the call 1700 August of Figure 19.8 by using the Black-Scholes formula with \(T=.25\). OIL CRUDE OIL...
-
A company issues a \(10 \%\) coupon bond that matures in 5 years. However, this company is in trouble, and it is estimated that each year there is a probability of .1 that it will default that year....
-
Consider a continuous-time environment, with \(e\) as a variable outside of the market. (a) Suppose the final payoff is \(V\left(x_{e}, T ight)=x_{e}(T)\). Find \(V\left(x_{e}, t ight)\). (b) Find a...
Study smarter with the SolutionInn App