Consider the following program written in a C-like syntax. Assume parameters are passed by value and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following program written in a C-like syntax. Assume parameters are passed by value and that this code compiles. int a, b, c, d; // global variables initially 0 void gl (int b; int c) { print ("%d %d %d sd", a, b, c, d); } void g2 (int a; int c) ( gl (a, c); } int g3 (int c; int a) { int b; b = 3; gl (a,b); { int c; int d; d = 4; c = 8; g2 (a,b); } gl (a,b); return b; void main() { int a; int b; a = 4; b = 5; a = g3 (b, c); g3 (b, a); // return value ignored What is the output of the program if static scoping is used? What is the output of the program if dynamic scoping is used? Just give the output. Do not give an execution trace. Consider the following program written in a C-like syntax. Assume parameters are passed by value and that this code compiles. int a, b, c, d; // global variables initially 0 void gl (int b; int c) { print ("%d %d %d sd", a, b, c, d); } void g2 (int a; int c) ( gl (a, c); } int g3 (int c; int a) { int b; b = 3; gl (a,b); { int c; int d; d = 4; c = 8; g2 (a,b); } gl (a,b); return b; void main() { int a; int b; a = 4; b = 5; a = g3 (b, c); g3 (b, a); // return value ignored What is the output of the program if static scoping is used? What is the output of the program if dynamic scoping is used? Just give the output. Do not give an execution trace.
Expert Answer:
Answer rating: 100% (QA)
Answer For static scoping Output 0 5 0 0 For dynamic scoping Output 0 3 8 4 Explanatio... View the full answer
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
The following is an adjusted trial balance of the General Funds of Barnes Nursing Home (non-profit). Barnes Nursing Home Adjusted Current Funds Trial Balance December 31, 2015 Unrestricted Restricted...
-
Assume that interest rates on 20-year Treasury and corporate bonds are as follows: T-bond = 7.72% A = 9.64% AAA = 8.72% BBB =10.18% The differences in rates among these issues were caused primarily...
-
Neo-Darwinism believes that new species develop through (A).Continuous variations and natural selection (B) Mutation with natural selection (C) Hybridization (D) Mutation
-
List and describe, what you believe to be, the three most important current security regulations for air cargo operations After researching air cargo security regulations (along with other safety and...
-
The table below lists weights (carats) and prices (dollars) of randomly selected diamonds. For the prediction interval, use a 95% confidence level with a diamond that weighs 0.8 carats. Find the (a)...
-
Does object-oriented technology help or hinder testing?
-
Your parents are considering investing in PepsiCo, Inc., common stock. They ask you, as an accounting expert, to make an analysis of the company for them. Fortunately, excerpts from a current annual...
-
How much money needs to be set aside every year, for the next 10 years, to purchase a crane? The money is expected to earn 7% interest compounded annually and yearly inflation is expected to be 4%....
-
Jenny Atkinson is reviewing employment offers. The employment offer from ILU, Inc. includes private health insurance that ILU, Inc. will purchase on her behalf. ILU Inc. will have to pay a $1,840...
-
Evander bought a house on June 1, 2021. The previous owners had been foreclosed on, and Evander was able to buy the house below market, for $155,000. He made no improvements while he owned it. On...
-
In the coming year, the Sandbergs expect a rental property investment costing \($120,000\) to have gross potential rental income of \($20,000,\) vacancy and collection losses equaling 5% of gross...
-
Prepare a report or exhibit showing how statistics are used in psychology.
-
A blower door test on a 30 ft 50 ft 9 ft house located in Denver, Colorado, revealed that under a 4-Pa pressure differential between indoors and outdoors, the leakage area is about 200 in. 2 . a....
-
Prepare a report or exhibit showing how statistics are used in business. Use a daily report of transactions on the New York Stock Exchange. What inferences can you make from the information reported?
-
In a judo hip throw, you pull your \(60-\mathrm{kg}\) opponent onto your back to bring her center of mass just above your hip and then rotate her about your hip. Assume that the lever arm distance of...
-
What will come in place of question mark (?) in the following question? 185% of 400 + 35% of 240 =? % of 1648 1. 75 2. 125 50 4. 1115 5. None of these 3.
-
Write a paper about medication error system 2016.
-
Write an evaluation of some programming language you know, using the criteria described in this chapter.
-
What are the language characteristics that make closures useful?
-
Describe the pairwise disjointness test.
-
A child on a sled slides down an icy slope, starting at a speed of \(2.5 \mathrm{~m} / \mathrm{s}\). The slope makes a \(15^{\circ}\) angle with the horizontal. After sliding \(10 \mathrm{~m}\) down...
-
You hold a puck at the top of an ice-covered ramp inclined at \(60^{\circ}\) with respect to the vertical. Your friend stands nearby on level ground and holds a ball at the same height \(h\) above...
-
You throw a ball straight up with an initial speed of \(10 \mathrm{~m} / \mathrm{s}\). (a) What is the ball's instantaneous acceleration at instant \(t_{1}\), just after it leaves your hand; at...
Study smarter with the SolutionInn App