GATE CSE
First time here? Checkout the FAQ!
x
0 votes
72 views
In the following program where is the variable a getting defined and where it is getting declared?

#include

int main()

{ extern int a;

printf("%d\n", a);

return 0;

} int a=20;

(a) extern int a is declaration, int a = 20 is the definition

(b) int a = 20 is declaration, extern int a is the definition

(c) int a = 20 is definition, a is not defined

(d) a is declared, a is not defined
asked in Programming by Veteran (13.2k points)   | 72 views
Answer is A .

Extern int a declares that there will be a variable a of integer type in upcoming lines.

Int a=20 defines the variable
is 'a' used in both places same??as it is outside main()

http://www.geeksforgeeks.org/understanding-extern-keyword-in-c/

Please refer to this link to know more about extern variables!!

Please log in or register to answer this question.

Related questions



Top Users Aug 2017
  1. ABKUNDAN

    4658 Points

  2. Bikram

    4032 Points

  3. akash.dinkar12

    3136 Points

  4. rahul sharma 5

    2856 Points

  5. manu00x

    2664 Points

  6. makhdoom ghaya

    2380 Points

  7. just_bhavana

    2040 Points

  8. Tesla!

    1756 Points

  9. pawan kumarln

    1574 Points

  10. learner_geek

    1558 Points


24,879 questions
31,952 answers
74,105 comments
30,065 users