1 votes 1 votes What is the output of the program: extern int a; main() { extern int a; printf(a); } Priyanka17 asked Oct 1, 2018 • edited Oct 1, 2018 by Priyanka17 Priyanka17 473 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply royal shubham commented Oct 1, 2018 i moved by Shaik Masthan May 10, 2019 reply Follow Share what is ur dobt here ??? –1 votes –1 votes Priyanka17 commented Oct 1, 2018 reply Follow Share what would be the output ? 0 votes 0 votes Please log in or register to add a comment.
Best answer 1 votes 1 votes It will throw a compile time error which would look something like : undefined reference to `a' because extern variable declarations look for a variable defined with the same name defined globally. Vikas Verma answered Oct 1, 2018 • selected Oct 1, 2018 by Priyanka17 Vikas Verma comment Share Follow See all 2 Comments See all 2 2 Comments reply Shaik Masthan commented May 10, 2019 reply Follow Share @logan1x, @Vikas Verma it's not compilation error, it's linking error ! 0 votes 0 votes logan1x commented May 23, 2019 reply Follow Share Can you mention your source please? like host the code on geeksforgeeks IDE and share the link here? 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes It will generate compilation error undefined symbol a But if declaration is done at global a like extern int a= 5; Then there will be no error and it will print 5. logan1x answered Oct 3, 2018 logan1x comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes it will print global variable a with same defined in main function . no need of externl in global declartion royal shubham answered Oct 2, 2018 royal shubham comment Share Follow See all 0 reply Please log in or register to add a comment.