Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


What are Storage Classes in C ?

Answers were Sorted based on User's Feedback



What are Storage Classes in C ?..

Answer / debasis roy

There are 4 storage classes in c
1. Auto
2. Static
3. Extern
4. Register

1. Auto :
A variable,defined normally without any storage specification is treated as automatic variable.
Example :

#include<stdio.h>
void main()
{
int num; //declaration of a variable num
num=7; //assign an integer to num
printf("%d",num);
}

output
7

2.Static :
A variable is declared as static when it needs to remember it's previous value.
To declare a variable as static an explicit mention of the word 'static' is necessary.
It can be used in recursion , a function that need to remember it's previous call's change etc.

Example:
#include<stdio.h>
void see_the_change(int);
void main()
{
see_the change(5);
see_the_change(60);
see_the_change(70);
}
void see_the_change(int vulejaoa)
{
static int capture;
cature=vulejaoa;
capture++;
printf("%d ",capture);
}

output :
6 7 8

3.Extern :
when a variable needs to be reused by different functions extern variables are used.
If we define something in a function and declare it externally then we can use it in that particular scope of funcion block.

Example :

#include<stdio.h>
int m;
void in_a();
void in_b();
void main()
{
extern int m;
m=10;
printf("%d",m);
in_a();
in_b();
}
void in_a()
extern int m;
m=19;
printf("%d",m);
}
void in_b()
{
extern int m;
m=52;
printf("%d",m);
}

4.Register :
Normally one should avoid this type as if your processor lacks more number of registers then system would have been slow down.
But if you have a processor having sufficient number of registers and you need to run it in less time, i.e without wasting any time, then you should go for a register variable.
As register variable declaration stores number stored in registers like A,B,C,D,E or H-L pair and eventually those are stored in cache memory, program can access it very fast. If all registers are used then the numbers will be stored in main memory.

Example :

#include<stdio.h>
void main()
{
register int m;
m=12;
printf("%d",m);
}

Is This Answer Correct ?    7 Yes 0 No

What are Storage Classes in C ?..

Answer / bibhuti bhusan basantaray

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 ?    17 Yes 11 No

What are Storage Classes in C ?..

Answer / bhagwan singh mer

if we declare any variable its type and storage class is
also be declare.storage class tells us that
1.where the variable is stored.
2.what is its initial value.
3.what is the scope of the variable.
4.and last is what is the life of the variable.
THERE ARE FOUR TYPES OF STORAGE CLASS IN C-
1.AUTOMATIC STORAGE CLASS
2.REGISTER STORAGE CLASS
3.STATIC STORAGE CLASS
4.EXTERNAL STORAGE CLASS

Is This Answer Correct ?    14 Yes 8 No

What are Storage Classes in C ?..

Answer / ramiz n sayyed

if we declare any variable its type and storage class is
also be declare.storage class tells us that
1.where the variable is stored.
2.what is its initial value.
3.what is the scope of the variable.
4.and last is what is the life of the variable.
THERE ARE FOUR TYPES OF STORAGE CLASS IN C-

1.AUTOMATIC STORAGE CLASS
2.REGISTER STORAGE CLASS
3.STATIC STORAGE CLASS
4.EXTERNAL STORAGE CLASS

Is This Answer Correct ?    8 Yes 3 No

What are Storage Classes in C ?..

Answer / sanath

Storage class determins the life time of the storage of an
identifier.
where the identifier is stored is determined by storage
class
Identifier means name given to a variable or a function.

There are 2 storage classes
1.Automatic storage class
2.static storage class

Automatic storage class
-----------------------
Variables declared within a function body are called
automatic variables.Auto is the keyword used to declare
automatic variables. By default and without the use of auto
keyword, the vaeiables inside the function are automatic
variables.auto matic variables are stored in stack.
Variables declared as register are also automatic they
are stored in fast registers of CPU.If sufficient number of
registers are not available, the register variables also
stored in stack.
When the function is calling these variables are
allocating memmory automatically. When the function is
finished and exits, the controll trnsfered to the calling
program the memory allocated will be destroyed.
2.Static storage class
-----------------------

Is This Answer Correct ?    6 Yes 2 No

What are Storage Classes in C ?..

Answer / milind rane.

Storage classes in c are as follows:
1)Automatic storage class.
2)Register storage class.
3)Static storage class.
4)External Storage Class.

And here value stored in CPU Register can always be accessed
faster than the one that is stored memory.

Hope the Ans. is correct!

Is This Answer Correct ?    8 Yes 4 No

What are Storage Classes in C ?..

Answer / sowmi

There are 4 types of storage class namely such as
auto,extern,static,register,and also type def

Is This Answer Correct ?    0 Yes 0 No

What are Storage Classes in C ?..

Answer / sanya

stroge refes to the scope of the variable and memory
allocatin by the compiler to store the varibl. scope of a
variable is the boundary within which a variable can be
used store class defines the scope and lifetime of variable.

from the point of c compiler,a variable name identifies
physical loction from from a computer where variable is
stored. there are to memory location in a computer system
where variable are stored as memory and cpu register

there are four type
1.automatic
2.register
3.static
4.external

Is This Answer Correct ?    0 Yes 0 No

What are Storage Classes in C ?..

Answer / sagar kolte & shakti panch

storage class is nothing but diffrent location laocation in
memroy::::
Storage class tells us:

1) Where the variable is stored.

2) Initial value of the variable.

3) Scope of the variable.Scope specifies the part of the
program which a variable is accessed.

4) Life of the variable.

there are 4 class
1) register -> (all the cpu reg)
2) auto -> scope is local to function perticular function

3) extern-> all global variables by default they are global
4) static ->Variable is stored in memory.

Default value is zero.

Scope is local to the block.

Life is,value of the variable persists between different
function calls.

Is This Answer Correct ?    0 Yes 0 No

What are Storage Classes in C ?..

Answer / yogeshwar parashar

definition of storage class:-
WHEN WE DEFINE ANY VARIABLE IN COMPUTER IT'S REQUIRE
SOME PHYSICAL LOCATION, TWO TYPES OF LOCATION HAS COMPUTER
1)COMPUTER MEMORY
2)CPU REGISTER.
STORAGE CLASS HAS SOME FEATURES FOR EVERY VARIABLE LIKE
A)LOCATION OR VARIABLE
B)INITIAL VALUE OF THE VARIABLE, IF IT IS NOT DEFINE THEN
WE FIND BY DEFAULT VALUE OR GARBEGE VALUE.
C)SCOPE (VISIBILITY) OF THE VARIABLE.
D)LIFE OF THE VARIABLE

THERE ARE FOUR TYPES OF STORAGE CLASSES IN C PROGRAMMING.

A) AUTOMATIC STORAGE CLASS
B) REGISTER STORAGE CLASS
C) STATIC STORAGE CLASS
D) EXTERNAL STORAGE CLASS
THANK YOU...
YOGESHWAR PARASHAR

Is This Answer Correct ?    0 Yes 0 No

Post New Answer



More C Interview Questions

Explain a file operation in C with an example.

0 Answers   Amdocs,


What is the proper way of these job Tell me about there full work

0 Answers   EDS,


What is the difference between exit() and _exit() function in c?

0 Answers  


where does it flourished?

0 Answers   Microsoft,


What is a null string in c?

0 Answers  






Is that possible to add pointers to each other?

0 Answers  


Explain what are run-time errors?

0 Answers  


which do you prefer C or Pascal?

1 Answers  


which one is highest Priority in c? a)=,b)+,c)++,d)==

4 Answers  


Explain what does the function toupper() do?

0 Answers  


a C prog to swap 2 no.s without using variables just an array?

5 Answers   TCS,


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

0 Answers   Wilco,






Categories