For each variable and parameter (totally 10 of them) in the C++ program shown be
ID: 664310 • Letter: F
Question
For each variable and parameter (totally 10 of them) in the C++ program shown below (you could answer a. b. together):
a. Categorize the variable/parameter lifetime as static, stack-dynamic, or heap-dynamic.
b. Clearly describe the scope of the variable/parameter.
c. Clearly describe the environment (in terms of which variables and parameters are accessible) at each numbered comment line
Explanation / Answer
arr,maxsize and i are stack dynamic
size and intarray are heap variables
calls is static variable
heap variables can be accessed by any subroutine and function.
stack based can be called by local scope and are de-allocated once the program execution is finishes
static variables retain thier value even after execution of the program scope finishes.
comment line 1 is heap dynamic
comment line 2 and 3 is stack dynamic
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.