Question: 3. (30 pts) Consider the following pseudocode: 1. 2. 3. procedure main a: integer :=1 b: integer :=2 4. 5. procedure middle b: integer :=a

 3. (30 pts) Consider the following pseudocode: 1. 2. 3. procedure

3. (30 pts) Consider the following pseudocode: 1. 2. 3. procedure main a: integer :=1 b: integer :=2 4. 5. procedure middle b: integer :=a 6. 7. procedure inner print a, b 8. a: integer :=3 9. 10. 11. // body of middle inner) print a, b 12. 13. 14. // body of main middle ) print a, b (a) Suppose this was code for a language with the declaration-order rules of C (but with nested subroutines) - that is, names must be declared before use, and the scope of a name extends from its declaration through the end of the block. At each print statement, indicate which declarations of a and b are in the referencing environment. What does the program print (or will the compiler identify static semantic errors)? Line 7 prints 3, 1 with a = 3 and b=1 when inner() is called. Line 11 prints 3, 1 with a =3 and b=1. Line 14 prints 1,2 with a = 1 and b=2 (b) Repeat the exercise for the declaration-order rules of C# (names must be declared before use, but the scope of a name is the entire block in which it is declared). (c) Repeat the exercise for the declaration-order rules Modula-3 (names can be declared in any order, and their scope is the entire block in which they are declared)

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!