Skip to content
Related Articles

Related Articles

C | Variable Declaration and Scope | Question 4

View Discussion
Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021
View Discussion
Improve Article
Save Article

#include <stdio.h>
extern int var = 0;
int main()
    var = 10;
    printf("%d ", var);
    return 0;

(A) 10
(B) Compiler Error: var is not defined
(C) 0

Answer: (A)

Explanation: If a variable is only declared and an initializer is also provided with that declaration, then the memory for that variable will be allocated i.e. that variable will be considered as defined.

Refer: Understanding “extern” keyword in C

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!