+ 2
The extern keyword indicates that this variable was defined elsewhere, for example, when creating large projects, all global variables can be stored in a separate file, and subroutines are scattered across other files.
That is, extern essentially copies the variable.
This increases the compilation speed.
In your case, extern is not required, "main" and this how sees the given variable.
+ 2
Mahmoud Osman
Because you declared two different variables, one global, the other local, and it will throw an error because the local variable is not used.
Write "return printf("%d%d", a, get_a());" and there will be an output: 65
+ 1
Verstappen
Because you are re-initialising a by 6 so your output will be 6
+ 1
Verstappen, I'm glad I was able to help you, you can mark my answer as the best ☺️
+ 1
😉
+ 1
Why not to :
int a = 5;
int get_a (void) {
return a;
}
int main(void) {
int a = 6;
return printf ("%d", get_a()) ;
}