Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Goal: Names, Bindings and Scope 1. The scopes created by blocks, which could be nested in larger blocks are treated exactly those created by nested
Goal: Names, Bindings and Scope 1. The scopes created by blocks, which could be nested in larger blocks are treated exactly those created by nested subprograms. C based languages Program Main; start Main ) do not have nested subprograms but they do have nested blocks. Create two nested blocks and declare variables of the same name. Assign values to those variables and print their values before you enter the block in the block and after you exit the block. Try it in Java and write down the difference, if there is any var r,v,a: integer procedure AREA: start AREA) begin a3 *r*r; endend AREA) procedure VOL3D start VOL3D) var a,r: integer; procedure MYPRINT: start MYPRINT.) begin println ("Volume is",v) println ("Area is ", a) Define static, stack-dynamic, explicit-heap dynamic and implicit-heap dynamic variables. Then, please write example lines of codes in C to represent each variable, if possible 2. endend MYPRINT) begin a1 AREA v - 4/3*r*a; MYPRINT: endend VOL3D) 3. Examine the following program. Assume static scoping is used. List all the variables that are visible begin at points (1), (2), (3), and 4) (referencing environment) and specify where they are declared Write down what gets printed. If dynamic scoping is used what would get printed. Also give the end. l end Main h referencing environment for dynamic scoping as well a0: VOL3D
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started