What are Storage Classes in C ?

Answer Posted / monika

There are four types of storage classes in c. It defines the
scope and lifetime of a variable or function.

1. auto - This is the default storage class. Auto can only
be used with in functions. i.e. only for local variables,
not for globals.

2. register - The variables declared using the register
storage class may stored in cpu registers instead of RAM.
Since it doesn't have a memory location, the '&' operator
for getting the address of the variable cannot be applied
(in C). This storage class cannot be used for global scope data.

3. static - This is the default storage class for global
variables. In case of local variable, it is initialized at
compile time and retains its value between the calls. By
default the static variables will be initialized to zero,
incase of pointer variable initialized to NULL.

4. extern - Defines the global variables that is visible to
all object modules. This type of variables cannot be
initialized, since it is pointing to a storage location,
where it is previously define.

Is This Answer Correct ?    31 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you do dynamic memory allocation in C applications?

619


What is scanf () in c?

652


Write a code of a general series where the next element is the sum of last k terms.

579


What is keyword with example?

621


Why clrscr is used in c?

570






Is this program statement valid? INT = 10.50;

677


What is pass by reference in functions?

313


Differentiate between declaring a variable and defining a variable?

596


What is clrscr in c?

662


What is logical error?

594


Explain output of printf("Hello World"-'A'+'B'); ?

966


Disadvantages of C language.

645


difference between native and cross compilers

1659


Write a code to generate a series where the next element is the sum of last k terms.

719


What the different types of arrays in c?

606