Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Scopes and Symbol Tables Consider the following code: 1 int a = 0 ; 2 int b = 0 ; 3 void print ( )

Scopes and Symbol Tables
Consider the following code:
1 int a =0;
2 int b =0;
3 void print (){
4 printf ("%d ,% d ", a , b );
5}
6
7 int fun1(){
8 int a , c ;
9 a =1; b =2; c =3;
10 print ()
11 return c ;
12}
13
14 void fun2( int c ){
15 int a ;
16 a =9; b = c ;
17 print ();
18}
19
20 int main (){
21 a = fun1();
22 fun2(8);
23 print ();
24 return 0;
25}
1. Draw the symbol tables in separation for all 5 scopes in this program. Assume each
table contains two columns: name and type.
2. What is the output of the above code with static scoping? Justify your answer by
showing the tree of the symbol tables.
3. What is the output of the above code with dynamic scoping? Justify your answer by
showing the tree of the symbol tables

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane A Z a/2 X a/2 a/2 Y

Answered: 1 week ago

Question

Explain the importance of nonverbal messages.

Answered: 1 week ago

Question

Describe the advantages of effective listening.

Answered: 1 week ago

Question

Prepare an employment application.

Answered: 1 week ago