1,946 views
1 votes
1 votes

If I write
 

#include<stdio.h>
int a;
main()
{
//code
}



then since a is a global variable so what is the storage class of it , is it extern ?

2 Answers

Best answer
3 votes
3 votes

No, it is of static storage class because you have also defined variable here.

If you have written extern int a;, then it would have been of extern storage class.

Ref: http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/CONCEPT/storage_class.html

selected by
0 votes
0 votes

in C ,by default global variable have extern  linkage

related  theory

Linkages of identifiers

3) If the declaration of a file scope identifier for an object or a function contains the storage-class specifier static, the identifier has internal linkage.

5) If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern. If the declaration of an identifier for an object has file scope and no storage-class specifier, its linkage is external.

reshown by

Related questions

1 votes
1 votes
2 answers
2
someshawasthi asked Nov 30, 2022
750 views
find the output of following programmain(){ extern int a; a=5; printf("%d",a);}
2 votes
2 votes
0 answers
3
K ANKITH KUMAR asked Aug 8, 2018
1,081 views
Q. What is the output of following program?int main(){ register int Data =10; int *piSumData = NULL; piSumData = &Data; *piSumData = 5; printf("%d",*piSumData); }1. Run ...