in Compiler Design edited by
2,497 views
2 votes
2 votes

Consider the following statements:
S1 : Static allocation can not support recursive function.
S2 : Stack allocation can support pointers but can not deallocate storage at run-time.
S3 : Heap allocation can support pointers and it can allocate or deallocate storage at run-time.
Which of the above statements are true?

S1 and S2

S2 and S3

S3 and S1

d  S1, S2 and S3

in Compiler Design edited by
2.5k views

4 Comments

Someone please answer.
0
0
Ans C

Stack allocation supports pointers, true, and with that stack allocation happens when stack function is called ,so, once the function call is over memory is deallocated i.e. deallocation of storage at run time.
0
0
I am confused in S2. Can anyone please confirms whether its true or false.
0
0

4 Answers

0 votes
0 votes
ANS is C
FOR S2
int **p = new int*;

In this case you reserve a portion of memory for a pointer to int in the heap, but the pointer that can reference such location is still a stack variable.

0 votes
0 votes
Answer should be D
0 votes
0 votes

Answer D s1s2 s3 all are true

0 votes
0 votes

TRUE   S1 : Static allocation can not support recursive function.

FALSE  S2 : Stack allocation can support pointers but can not deallocate storage at run-time.

Stack memory is allocated during compilation time execution. This is known as static memory allocation.

https://iq.opengenus.org/static-memory-allocation-c/

TRUE   S3 :  Heap allocation can support pointers and it can allocate or deallocate storage at run-time.

 

Related questions