0
694views
What is use of storage classes? Explain extern storage classes with suitable example
1 Answer
0
1views

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:

  1. In this case data is stored in memory.

  2. The initial variable of such variable is zero.

  3. The scope of the variable is zero i.e. it is accessible from anywhere in the program.

  4. The life of such variable is till the program is alive.

  5. 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
Please log in to add an answer.