C | Variable Declaration and Scope | Question 3

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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


Answer: (A)

Explanation: var is only declared and not defined (no memory allocated for it)

Refer: Understanding “extern” keyword in C

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.