Question: 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 :

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!