


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















its storage class as default i.e.
variable name;
auto int a ,b ;
Storage Memory Initial Value Garbage Value i.e. An Unpredictable Value. Scope or Visibility Local or Visible in the Block in which it is declared. Life Time It retains its value till it is in the
auto int a ;
Void main ( ) { auto int i , j = 5 ;
Automatic Storage Class^ int k^ ,m =10 ;^ // By Default
of j = % d^ printf ( “ value of “ , i , j ) ;^ i^ = % d^ \n value
of m = % d^ printf ( “ value of “ , i , j ) ;^ k^ = % d^ \n value }
Value of i = 2009 Value of j = 5 Value of k = 1005 Value of m = 10
Garbage Value Variable Value
clrscr ( ) ; ck ( ) ; ck ( ) ; ck ( ) ; getch( ) ; }
void ck ( ) { int i = 0 ; %d”,i ) ;^ printf ( “\n\n Value of I .. i + + ; } (^) Output 0 0 0
In this storage class , variable is stored in C P U Registers , just for the sake of increase the execution speed of some variable of
register int a ;
Storage Memory Initial Value Zero ( 0 ) Scope or Visibility Local to the block in which it is declared Life Time It retains its value between the
clrscr ( ) ; ck ( ) ; ck ( ) ; ck ( ) ; getch( ) ; }
void ck ( ) { static int i = 0 ; %d”,i ) ;^ printf ( “\n\n Value of I .. i + + ; } (^) Output 0 1 2
16
Internal static variable can be used to count function. eg. the number of calls made to int { main() int for(i I; =1; i<=3; i++) }^ stat(); void { stat() static x = x+1; int x=0; }^ printf(“x^ =^ %d\n”,x);
Output x= x= x=
17
An external static variable is declared outside of all functions and is available to all the functions in the program. An external static variable seems similar simple external variable but their difference is that static external variable is available only within the file where it is defined while simple external variable can be accessed by other files.
Storage Memory Initial Value Zero ( 0 ) Scope or Visibility Global ( Visible in all the Program ) Life Time It retains its value through out the
is declared as follow : - extern int a ;
20
External declaration(examples) int { main() extern... int y;
}^.^.^. func1() { extern... int y;
}^..^. int y;
Note that extern declaration does not allocate storage space for variables