The following questions refer to the skeletal C++ 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 that are visible at Line 2.
(c) Repeat part (a), but list the variables that are visible at Line 3.
(d) Repeat part (a), but list the variables that are visible at Line 4.
(e) Repeat part (a), but list the variables that are visible at Line 5.
(f) Assume that dynamic scoping is used, and that main calls f1, which calls f2. (Assume that f1 calls f2 on Line 3.) List all variables, along with the functions in which they are declared, that are visible at Line 5 in the program.
void fl ();
void f2();
int a, b, c;
int main()
{int a, b, d; ...
//Line 1}
void fl()
{int d, e;
if (...)
{int a, b; ...
//Line 2} ...
//Line 3}
void f2()
{int a, c; if (...)
{int b, c; ...
//Line 4} ...
//Line 5}
Here's an example of the format that you should use for your answers: a (global), d (declared in fl), e (declared in if block in fl)

Solved
Show answers

Ask an AI advisor a question