C++ The following questions refer to the skeletal C++ program shown below. (a) A
ID: 3805678 • Letter: C
Question
C++
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 fl, which calls f2. (Assume that f 1 calls f 2 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 f1(); void f2(); int a, b; int main() {int c, d, e; ellipsis//Line 1} void f1() {int b, c, e; if (ellipsis) {int b, d; ellipsis//Line 2} ellipsis//Line 3} void f2() {int a, c, e; if (ellipsis) {int b, e; ellipsis ellipsis//Line 4}//Line 5 A sample answer to one part of the problem might look like this: a (global), b (declared in if block in f 1), c (declared in f 1)Explanation / Answer
a) , a(global) , b(global) ,c (declared in main), d (declared in main) , e (declared in main)
b). a(global) , b(declared in if block of f1) , c(declared in f1) , d(declared in if block of f1) , e(declared in f1)
c), a(global) , b(declared in f1) , c(declared in f1) , e(declared in f1)
d) a(declared in f2) , b(declared in if block of f2) , c(declared in f2) , e(declared in if block of f2)
e) a(declared in f2) , b(global) , c(declared in f2) , e(declared in f2)
f) a(declared in f2) , b(declared in f1) , c(declared in f2) , e(declared in f2)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.