1. Examine the function below and answer the following questions. int gLobal = 2
ID: 3909477 • Letter: 1
Question
1. Examine the function below and answer the following questions.
int gLobal = 25; // declared outside function
int func( int X, char *Y, BYTE Z )
{
int a;
char b[] = “The lazy dog ate the red fox before jumping over it.”
char *c;
c = (char *) malloc(512K);
a = b[0];
return a;
}
a. What is the classification of memory in which the following are stored. (Program, Stack, or Heap)
i. X
ii. Y
iii. a
iv. c
v. The elements in the variable ‘c’.
vi. gLobal
vii. The array variable ‘b’.
viii. The elements in the variable ‘b’.
ix. The text string for ‘b’.
Explanation / Answer
Parameter values to functions are stored on the stack.
i. X ->Stack
ii. Y->Stack
iii. a->Stack [Local variables are stored in Stack]
iv. c->Stack
v. The elements in the variable ‘c’.->Heap
vi. gLobal->Program
vii. The array variable ‘b’.->Stack
viii. The elements in the variable ‘b’.->Stack
ix. The text string for ‘b’.->Stack
Thanks, Let me know if there is any doubts
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.