in Programming in C recategorized by
340 views
5 votes
5 votes

What is a statically allocated variable in C programming?
 

  1. A variable allocated at an absolute address in a program’s data space
  2. A variable allocated on the stack
  3. A variable allocated on the heap
  4. A variable which can NOT be defined as local variable
in Programming in C recategorized by
340 views

2 Answers

1 vote
1 vote
A statically allocated variable in C programming is a variable that is allocated at an absolute address in a program's data space. Statically allocated variables are typically defined at compile-time and have a fixed, unchanging memory location throughout the program's execution.

So, the correct option is:

A variable allocated at an absolute address in a program’s data space.
1 vote
1 vote
The value of variable in stack may be lost when we call another function or when we enter a block. so option b is incorrect.

Heap is a dynamic allocation part, we need the value of a variable to be static, so option c is incorrect.

Global variable also cannot be declared as local variable, so option D is incorrect.

When we store the value in an absolute address in program data space, the value of variable persists, So option A is correct.
Answer:

Related questions