0 votes 0 votes #include <stdio.h> /* global variable declaration */ int g = 20; int main () { /* local variable declaration */ int g ; printf ("value of g = %d\n", g); return 0; } why this printing value of g is 0 instead of garbage because g is declared which is local variable in main function. are variables inside main function by default global? Programming in C programming-in-c + – Ram Swaroop asked Mar 17, 2019 Ram Swaroop 412 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply abhishekmehta4u commented Mar 17, 2019 reply Follow Share It should be garbage. 0 votes 0 votes Ram Swaroop commented Mar 17, 2019 reply Follow Share answer is 0 https://ideone.com/fork/A00bGd 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes no, by default variables inside main function is not by default global Aprajita sachdev answered Mar 22, 2019 Aprajita sachdev comment Share Follow See all 0 reply Please log in or register to add a comment.