1,501 views

1 Answer

Best answer
0 votes
0 votes

Output will be :

66

 warning: ‘a’ initialized and declared ‘extern’
 extern int a = 6;
 

Extern keyword is the way we can declare a variable without actually defining it. But here we are declaring the variable and initializing at the same time which means that the memory is being allocated, which again means that the definition of the variable is given.

Hence, the compiler will show the warning message though it will compile successfully.

Declaration: Memory is not allocated only the prototype is given, that is the type of the arguments, return type etc.

Definition: Memory is allocated.

selected by

Related questions

1 votes
1 votes
0 answers
1
2 votes
2 votes
2 answers
2
targate2018 asked Jan 15, 2018
1,445 views
extern int i; int i = 10; i = 5; int main() { printf("%d", i); return 0; }The output for the above code is _______
2 votes
2 votes
1 answer
3
rahul sharma 5 asked Nov 23, 2017
1,055 views
#include <stdio.h int main() { int a=10; extern int a; return 0;} Why this gives compilation error? Extern is just a declaration.So why it is giving error on c...