The following questions refer to the skeletal C++ program shown below. Assume th
ID: 3802790 • Letter: T
Question
The following questions refer to the skeletal C++ program shown below. Assume that static scoping is used. List all variables, along with the which they are declared, that are visible at Line 1 in the program. Repeat part (a), but list the variables that are visible at Line 2. Repeat part (a), but list the variables that are visible at me. Repeat part (a), but list the variables that are visible at Line 4. Repeat part (a), but list the variables that are visible at Line 5. 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 f1(); vold f 2(); int. a, b; int main{) { int: c, a. e; ... // Line 1 } void f1 () { int: b, c, e; if (-) { int b, d; ... // Line 2 ) ... // Line 3 ) void f2 () { int a, c, e; if (...) { int b, e; ^ // 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 f1)Explanation / Answer
a) a (global), b(global), c (main), d(main), e(main)
b) a(global), b(declared in if block in f1), c(declared in f1), d(declared in if block in 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 in f2), c(declared in f2), e (declared in if block in f2)
e) a(declared in f2), b(global), c(declared in f2), e (declared in if block in f2)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.