Storage-Classes
Question 1 |
The default storage class for functions in ‘C’ language is:
Static | |
Register | |
Extern | |
Auto |
Question 1 Explanation:
The default storage class for variable is auto and function is extern.
We can use functions in multiple files with the help of header files.
We can use functions in multiple files with the help of header files.
Question 2 |
A static variable is one :
Which cannot be initialized | |
Which is initialized once at the commencement of execution and cannot be changed at runtime | |
Which retains its value throughout the life of the program | |
Which is the same as an automatic variable but is placed at the head of a program |
Question 2 Explanation:
A static variable is one which retains its value throughout the life of the program. The static storage class instructs the compiler to keep a local variable in existence during the life-time of the program instead of creating and destroying it each time it comes into and goes out of scope.
Question 3 |
Which of the following storage classes have global visibility in C/C++ ?
Auto | |
Extern | |
Static | |
Register |
Question 3 Explanation:
→ Register and auto variables have limited scope (the block in which they are declared) and limited lifetimes (as for automatic variables). However, in some applications it may be useful to have data which is accessible from within any block and/or which remains in existence for the entire execution of the program. Such variables are called global variables. The scope of external variables is global.