0
839views
What is use of storage classes? Explain extern storage classes with suitable example
1 Answer
written 5.6 years ago by | • modified 5.6 years ago |
1.The different locations I the computer where we can store data and their accessibility, initial values etc. vary based on the way they are declared. These different ways are termed as different storage classes.
2.In C, we have four storage classes namely
i. Automatic
ii.Register
iii.Static
iv.Extern or Global.
Extern Classes:
In this case data is stored in memory.
The initial variable of such variable is zero.
The scope of the variable is zero i.e. it is accessible from anywhere in the program.
The life of such variable is till the program is alive.
Example
Program:
#include<stdio.h>
#include<conio.h>
int a=5;
void main
{
int a=10;
printf(“%d\n”,a);
printf(“%d\n”,::a);
a=::a+a;
printf(“%d\n”,a);
printf(“%d\n”,::a);
::a=a;
printf(“%d\n”,a);
printf(“%d\n”,::a);
getch();
}
Output:
10
5
15
5
15
15