1. The following questions refer to the skeletal Ct+ program shown below (a) Ass
ID: 3604314 • Letter: 1
Question
1. The following questions refer to the skeletal Ct+ program shown below (a) Assume that static scoping is used. List all variables, along with the functions in which they are declared, that are visible at Line 1 in the program. (b) Repeat part (a), but list the variables along with the functions in which they are declared that are visible at Line 2 (c) Repeat part (a), but list the variables along with the functions in which they are declared that are visible at Line 3. (d) Repeat part (a), but list the variables along with the functions in which they are declared that are visible at Line 4. (e) Repeat part (a), but list the variables along with the functions in which th are declared that are visible at Line 5 (1) Assume that dynamic scoping is used, and that main calls fl, which calls (Assume that fl calls f2 on Line 3.) List all variables, along with the functions which they are declared, that are visible at Line 5 in the program. void f10 void £20 int a, b, c int maino int a, b, di I Line 1 void f1 int d, e it int a, bi Line 2 I1 Line 3 void f20 int a, C if ) ( // Line 4 // Line SExplanation / Answer
int a=1,b=2,c=3;
int main()
{
int a,b,d;
a=4;
b=8;
d=9;
f1();
f2();
}
void f1()
{
int d,e;
if(d==e)
{
int a,b;
a=8,b=7;
f2();
}
return f1();
}
void f2()
{
int a,c;
a=8;
c=9;
if(a==c)
{
int b,c;
b=8;c=10;
f1();
}
return f2();
}
Dynamic scoping
int main()
{
int a,b,d;
a=2;b=3;d=5;
f1();
f2();
}
void f1()
{
int d,e;
if(d==e)
{
int a,b;
a=8,b=7;
}
f2();
}
void f2()
{
int a,c;
a=88;c=99;
if(a!=c)
{
int b,c;
b=44;
}
return f2();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.