variable types Flashcards

1
Q

where is global allocation stored

A

in the data area of main memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

where automatic allocation stored

A

on the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

where is static allocation stored

A

in the data area of main memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

where is dynamic allocation stored

A

on the heap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the visibility of the object in global allocation

A

the whole process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the visibility of the object in automatic allocation

A

within the block that it is declared

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the visibility of the object in static allocation

A

within a single file or within its enclosing block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the visibility of the object in dynamic allocation

A

wherever there is a pointer/reference to it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the lifetime of variable in global allocation

A

for the execution of the process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the lifetime of variable in automatic allocation

A

while the block is executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the lifetime of variable in static allocation

A

for the execution of the process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the lifetime of variable in dynamic allocation

A

until it is explicitly deallocated using free() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is the dynamic memory function which allows memory to be allocated

A

malloc(), the parameter within will take the size of memory which is required.
int* c = (int*)malloc(sizeof(int))
*c = b
* is a pointer to a variable whose datatype is an integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is the dynamic memory function which allows memory to be deallocated

A

free(), the parameter taken is whatever the allocation variable was saved as
in our code it was *c

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

when is memory available for re-use in global allocation

A

when the process terminates

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

when is memory available for re-use in automatic allocation

A

when the function returns or at block closure

17
Q

when is memory available for re-use in static allocation

A

when the process terminates

18
Q

when is memory available for re-use in dynamic allocation

A

when free() is called