What are Storage Classes in C ?
Answers were Sorted based on User's Feedback
Answer / shashi sourabh kant
There are four type of storage classes in C. These are used
to store variables. These are Extern, Static, Register and
Auto. Auto is the default class assigned to any variable.
eg. if we define int x=10; then it means auto int x=10
register and static differ in only one grounds that
register is there in the cpu and static in the main memory.
extern is global and can be accessed by any program and
anywhere.
Is This Answer Correct ? | 704 Yes | 59 No |
Answer / santhi
there are 4 types of storage classes.they are-
extern,auto,register,static.
Is This Answer Correct ? | 441 Yes | 50 No |
Answer / thomas
Basically, storage classes in c are there to define the
storage & scope of the various sorts of variables.
we r having following 4 storage classes in C.
01.auto
02.register
03.extern
04.static
In this auto & register has local scope releted to block &
extern & static has global scope to main program.
Is This Answer Correct ? | 129 Yes | 21 No |
Answer / pranab kumar rana
According to denis ritchie there are 5 types of storage classes
1. auto
2.static
3.register
4.extern
5. typrdef
you all know about the abobe 4 types but in typedef is
actually not used as a storage class . but when it combines
with a variable it comes to the resolution
'
Is This Answer Correct ? | 127 Yes | 46 No |
Answer / ajith
#include<stdio.h>
void main()
{
int a,s; /*** local variable****/
printf("\n enter the value of a---");
scanf("%d",&a);
s=a+2;
printf("s=%d",a);
getch();
}
output--
enter the value of a--- 5
s=7
example of global variable----
#include<stdio.h>
int a; /***global variable*********/
void main()
{
int s;
printf("\n enter the value of a--");
scanf("%d",&a);
s=a+3;
printf("\n s=%d",a);
mul(); /****another function********/
getch();
void mul()
{
int m;
m=a*2;
printf("\n m=%d",a);
}
output---
enter the value of a----5
s=8
m=10
///*********************************////
Is This Answer Correct ? | 70 Yes | 27 No |
Answer / priya
WHEN we define any funtion in c program then we
can call that in every definend class.
there are four types of storage class. they are
1 AUTO OR AUTOMATIC STORAGE CLASS
2 REGISTER STORAGE CLASS
3 STATIC STORAGE CLASS
4 EXTERNALSTORAGE CLASS
Is This Answer Correct ? | 31 Yes | 1 No |
Answer / 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 |
Answer / laxmikant
C supports 4 types of storage class. They are given
hereundr:-
1> Extern
2> static
3> Register
4> Auto
By default a variable defined inside a block is a auto
variable.It has block level scope.Regsiter storage class
indicates that the variable is stored in the CPU rather
than Memory. So the opeartion is faster because accessing
register is faster then memory.Extern indicates that the
effect of the variable is realised in every object modules.
And finally static .If it is defined inside the
function ,then it's retian its value during different
function call.And it's life is through out the program.And
it's initilized only once.
Is This Answer Correct ? | 27 Yes | 9 No |
Answer / vagish
storage class contains five types of storage class in c .
I. Extern
II. Static
III. Register
IV. Auto
V. typedef
I. Auto - This is the default storage class. Auto can only
be used with in functions. i.e. only for local variables,
not for globals.
II. 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.
III. 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.
IV. 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.
V. Typedef- A typedef declaration lets you define your own
identifiers that can be used in place of type specifiers
such as int, float, and double. A typedef declaration does
not reserve storage. The names you define using typedef are
not new data types, but synonyms for the data types or
combinations of data types they represent.
Is This Answer Correct ? | 23 Yes | 7 No |
Answer / vijayalakshmi
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 ? | 12 Yes | 2 No |
What happens if header file is included twice?
What is diffrance between declaration and defination of a variable or function
If fflush wont work, what can I use to flush input?
what is difference between array of characters and string
Explain the binary height balanced tree?
how to display 2-D array elements in spiral
How many types of operators are there in c?
What is the most efficient way to count the number of bits which are set in a value?
What are the different types of errors?
How can I recover the file name given an open stream?
the real constant in c can be expressed in which of the following forms a) fractional form only b) exponential form only c) ascii form only d) both a and b
What is Generic pointer? What is the purpose of Generic pointer? Where it is used?