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 is declaration and definition in c?
Where define directive used?
Between macros and functions,which is better to use and why?
Which of the following is not an infinite loop ? a.while(1){ .... } b.for(;;){ ... } c.x=0; do{ /*x unaltered within theloop*/ ... }while(x==0); d.# define TRUE 0 ... while(TRUE){ .... }
main() { int a[3][4] ={1,2,3,4,5,6,7,8,9,10,11,12} ; int i, j , k=99 ; for(i=0;i<3;i++) for(j=0;j<4;j++) if(a[i][j] < k) k = a[i][j]; printf("%d", k); }
4 Answers Vector, Wipro, Zoho,
Tell me when is a void pointer used?
Can two or more operators such as and be combined in a single line of program code?
Function to find the given number is a power of 2 or not?
What is an endless loop?
What is meaning of "Void main" in C Language.
24 Answers Ford, GU, HCL, IBIBS, JUW, TCS,
What is line in c preprocessor?
Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?