About C Language Interview Questions – Storage Classes
This page providing all the frequently asked C Interview questions of Storage classes in C language. These C Language Interview questions make you perfect in the concept of variables and their storage classes.
C Interview Questions-Storage Classes
What is Storage class?
Variable declaration completes not only with data type also includes its storage class.
Do we need to specify storage class of variable?
No, if we don’t specify compiler will write one storage class depends on the context of the variable in which it has declared.
What storage class describes?
Can we define auto variable globally?
No, auto variable declaration always belongs to block or function.
Where static variables get memory allocation?
Inside RAM memory.
Differentiate auto and register variables?
auto variables get memory allocation inside RAM whereas register variables get memory in CPU registers.
register variables can be accessed faster than auto variables.
Why can register variables not be global?
register variables are temporary variables used to execute block or function much faster. Hence these variables cannot be global.
What is the default value of a static variable?
The default value is Zero
Can we store static variables locally?
static variables can be either local or global
What is extern storage class?
used to declare the information globally in the c application.
Can we use an extern variable without initialization?
extern variables get memory allocation only if we initialize in its declaration. Hence we cannot use without initialization.