Storage Class in C by R4R Team

Storage Classes in C language defines the Scope of the Variable in the Entire program.
There are 4 Storage Classes in C language :

1.auto
2.register
3.static
4.extern

1.auto:

-By default , for every local variable auto class is selected.
Syntax-
int var;
or
auto int var;
Above both way is correct to define a auto variable.

2.register:

-By using this class, variable can store in directly in register instead of the RAM.

Syntax-
register type variable;

Example-
register int a;
register float b;
register char c;

3.static :

- By using this class, the existance of the local variable is become the life time of the program.

Syntax-
static type variable

4.extern :

-By using this class, the scope of the variable is become widely. means we can excess this variable from anywhere in the entire program.


program-

#include< stdio.h>
int main()
{
#include
int main()
{
auto int a=1;
static int b=2;
register int c=3;
extern int d=4;
printf("%d\n",a);
printf("%d\n",b);
printf("%d\n",c);
printf("%d\n",d);
}


output-

1
2
3
4




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!