Introduction of Storage Classes
Storage class is used to fully define any variable .Every variable not only has a data type but also a storage class associated with it . Storage class associated with it . Storage class provides the complete meaning to any variable .if we do not specify any storage class , compiler will assume a default storage class and handles that variable accordingly . There are four types of storage classes .
1 Auto
2 Static
3 External
4 Register
1 Auto it means automatically .it is the default scope of variable and they are declared with or without auto keyword . belong to auto storage class .Auto variables are active in the block in which they are declare .
Programe
#include<stdio.h>
#include<conio .h>
void main ( )
{
auto int a;
clrscr( );
printf (" the value jof a = %d ", a);
getch ();
}
2 Static static variable are those variable which start with static keyword .static variable retain their values through out the execution of the program .Their initial value is zero . The declaration part of static variable execute only once even if we call function more than once static variables are mostly used in functions
3 External These are those variables which are declared outside of the block /main .These variables are accessible to each block of the program .They are also know as global variables .These are declare with the extern keyword
4 Register register variables are those variables which start with register keyword .we can use register keyword to increase the speed of program .The Register variable uses the CPU memory and their default value is garbage .They are also block level variables which can access within the block where they are declared .
Programe
#include<stdio.h>
#include<conio .h>
void main ( )
{
register int a;
clrscr( );
printf (" the value jof a = %d ", a);
getch ();
}








0 comments:
Post a Comment