Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. The following questions refer to the skeletal C++ program shown below. (a) Assume that static scoping is used. List all variables, along with the
3. 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 at are visible at Line 1 in the program. If the variable was declared within an if statement, state which if statement (e.g. a (if of f1)) (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 Line3 (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 fl, which calls f2 (Assume that fl calls f2 on Line 2.) List all variables, along with the functions in which that are visible at Line 4 in the program. If the variable was declared within an if statement, state which if statement (e.g. a (declared in if block of f1)) void f1 void f2 ); void f3 ); int a, b, c; int main() int a, b, d; // Line 1 void fl () int b, e; ...// Line 2 void f2 () int a; int a, b, c; // Line 3 .. // Line 4 void f3 () int b, f; // Line !5 A sample answer to one part of the problem might look like this a (global), b (declared in if block in fl), c (declared in f1)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started