C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 10)
10.
In the following program where is the variable a getting defined and where it is getting declared?
#include<stdio.h>
int main()
{
    extern int a;
    printf("%d\n", a);
    return 0;
}
int a=20;
extern int a is declaration, int a = 20 is the definition
int a = 20 is declaration, extern int a is the definition
int a = 20 is definition, a is not defined
a is declared, a is not defined
Answer: Option
Explanation:

- During declaration we tell the datatype of the Variable.

- During definition the value is initialized.

Discussion:
46 comments Page 5 of 5.

Vishu said:   9 years ago
@Prathyusha.

You are right, answer A is corret.

Anjali agarwal said:   1 decade ago
What is extern? please explain me?

Om tripathi said:   2 decades ago
int a=20; is outside the main

Murali krishna said:   1 decade ago
What is the use of "extern" ?

Ramya said:   10 years ago
Will you explain please?

Bhavana said:   1 decade ago
I agree with prathyusha.


Post your comments here:

Your comments will be displayed after verification.