12th Dec 2021, 10:05 AM
gaurav kumar
gaurav kumar - avatar
2 Respostas
+ 2
●So its related to global variable and local variable. ●So when int i is declared in f() it is different from global i=10 initialized at first.so as function call ends local i dies. ●but in g() i is reassigned 9 without declaring.so the compiler presumes it as global i.hence, the global i is now 9. Am i correct?
12th Dec 2021, 10:15 AM
gaurav kumar
gaurav kumar - avatar
0
You are correct! Notice, too, that you get a warning on unused variable i in f(), but not in other places.
13th Dec 2021, 9:01 PM
Brian
Brian - avatar