in Programming in C
1,303 views
1 vote
1 vote
What is dynamic variable.? Is there any benefit of using dynamic variable instead of static variable?
in Programming in C
by
1.3k views

1 Answer

7 votes
7 votes
Best answer

A dynamic variable is a variable whose address is determined when the program is run. In contrast, a static variable has memory reserved for it at compilation time.

Dynamic variables provide flexibility. I mean that in dynamic variables, we do not have to mention the data type of variables at compile time, it can be decided by compiler on the basis of input values.

For example: Python, JavaScript etc have facility of dynamic variables. 

selected by
by

4 Comments

Every program while running in OS ,needs unique address space in virtual memory and it should be continuous.

Not always physically continuous

If program needs more memory that is more than RAM holds

by the use of virtual address space , part of hard disk mapped in real memory

OS maintains page table for look after which virtual address is mapped to which physical address. right?

 

Another question

@Arjun Sir @Manoj

What is the relationship between heap and offset
0
0
Heap is a memory area where allocation and de-allocation is done manually.

Whereas the offset specify entire address space .So i think heap is a portion of address space(i.e. offset).
1
1
@Manoj actually all page offset and page number stored in heap but when page is deleted then heap has to delete the pointer of page offset to page. rt?

@Arjun sir

physical address can be calculated by programmer adding logical address with base address . rt?

yes it is just a location where the pointer only access it.

But it cannot be seen by it user for its huge size .Now right?
0
0