External Storage
Class is a type of storage class. Extern storage class variables are stored in
memory. The default initial value of extern storage class variables is 0
(zero), unless they are initialized explicitly.
The scope of extern storage
class variables is global, and the life time of the variable, persists as long
as the program’s execution doesn’t come to an end.
Ex:
#include<stdio.h>
#include<conio.h>
void increment();
void decrement();
int x = 10;
void main( )
{
printf ( "\n X = %d", x )
;
increment( ) ;
increment( ) ;
decrement( ) ;
decrement( ) ;
}
void increment( )
{
x = x + 1 ;
printf ( "\n After Increment x
= %d", x ) ;
}
void decrement( )
{
x = x - 1 ;
printf ( "\n After Decrement x
= %d", x ) ;
}
Output:
x = 10
After Increment x = 11
After Increment x = 12
After Decrement x = 11
After Decrement x = 10
No comments:
Post a Comment