743 views
1 votes
1 votes
find the output of following program

main()
{
    extern int a;
    a=5;
    printf("%d",a);
}

2 Answers

Best answer
1 votes
1 votes

it will give error.

because extern keyword is use for just for declaration of variable.

it simply means variable’s definition is somewhere in code.

that is why it give undefined reference error.

selected by
0 votes
0 votes
It will not give any compile time error but will give a runtime error (undefined symbol)!

Related questions

2 votes
2 votes
0 answers
1
K ANKITH KUMAR asked Aug 8, 2018
1,066 views
Q. What is the output of following program?int main(){ register int Data =10; int *piSumData = NULL; piSumData = &Data; *piSumData = 5; printf("%d",*piSumData); }1. Run ...
1 votes
1 votes
2 answers
2
radha gogia asked Aug 9, 2015
1,918 views
If I write #include<stdio.h int a; main() { //code }then since a is a global variable so what is the storage class of it , is it extern ?
1 votes
1 votes
1 answer
4
Sparsh-NJ asked Jul 15, 2023
371 views
Can an array store elements of different storage classes?