#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?
answer is 0
https://ideone.com/fork/A00bGd
64.3k questions
77.9k answers
244k comments
80.0k users