GATE CSE
First time here? Checkout the FAQ!
x
0 votes
62 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)   | 62 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 Jun 2017
  1. Bikram

    3704 Points

  2. Arnab Bhadra

    1502 Points

  3. Hemant Parihar

    1502 Points

  4. Niraj Singh 2

    1481 Points

  5. junaid ahmad

    1432 Points

  6. Debashish Deka

    1384 Points

  7. Rupendra Choudhary

    1220 Points

  8. rahul sharma 5

    1220 Points

  9. Arjun

    1168 Points

  10. srestha

    1010 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 26 - Jul 02
  1. Arjun

    208 Points

  2. akankshadewangan24

    152 Points

  3. Debashish Deka

    138 Points

  4. Hira Thakur

    130 Points

  5. Soumya29

    106 Points


23,399 questions
30,111 answers
67,490 comments
28,426 users