Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Consider the following skeletal Ada program: procedure Main is X : Integer, procedure Sub3; -- This is a declaration of Sub3 It allows Subl to
Consider the following skeletal Ada program: procedure Main is X : Integer, procedure Sub3; -- This is a declaration of Sub3 It allows Subl to call it procedure Subl is X : Integer; procedure Sub2 is begin -- of Sub2 end; -- of Sub2 begin -- of Subl end; -- of Subl begin -- of Sub3 end; -- of Sub3 procedure Sub3 is begin -- of main end; - of main Assume that the execution of this program is in the following unit order: Main calls Subl Sub1 calls Sub2 Sub2 calls Sub3 Assuming static scoping in the following, which declaration of X is the correct one for a reference to X in each of the following subprograms? [5 points] a. Subl (which declaration of X does Subl refer to?) b. Sub2 (which declaration of X does Sub2 refer to?) c. Sub3 (which declaration of X does Sub3 refer to?) Explain your answers. Repeat part a, but assume dynamic scoping. [5 points]
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