What are Storage Classes in C ?

Answers were Sorted based on User's Feedback



What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

Answer / santhi

there are 4 types of storage classes.they are-
extern,auto,register,static.

Is This Answer Correct ?    441 Yes 50 No

What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

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

What are Storage Classes in C ?..

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

Post New Answer

More C Interview Questions

what is the diff between the printf and sprintf functions?? and what is the syntax for this two functions ??

5 Answers  


How we can set and clear bit in a byte using macro function?

2 Answers   L&T, Samsung,


Write a c pgm for leap year

11 Answers   College School Exams Tests, IBM, TCS,


in one file global variable int i; is declared as static. In another file it is extern int i=100; Is this valid ?

4 Answers   Infosys, NetApp,


write a program to find the frequency of a number

4 Answers   Infosys,






Explain what does the format %10.2 mean when included in a printf statement?

0 Answers  


What is the difference between null pointer and void pointer

10 Answers   CTS, Manforce, MAQ Software,


What's the difference between constant char *p and char * constant p?

0 Answers   Celstream,


What is the output of the following program #include<stdio.h> main() { int i=0; fork(); printf("%d",i++); fork(); printf("%d",i++); fork(); wait(); }

8 Answers   ADITI, Adobe,


What is the code in while loop that returns the output of given code?

0 Answers  


Which of the following are valid "include" formats? A)#include and #include[file.h] B)#include (file.h) and #include C)#include [file.h] and #include "file.h" D)#include <file.h> and #include "file.h"

15 Answers   Accenture,


What is new line escape sequence?

0 Answers  


Categories