0 0 votes Q. int k; fun(int i) { k = i + 3; printf(k); } gun( int i) { int k = 4; k = i+4; fun(k); printf(k); } main(){ k=2 ; gun(k); printf(k); } my result static scoping - 9,6,2 ( here last print statement i have doubt ..it will print 2 or 9) dynamic scoping- 9,9,2 Programming in C programming-in-c static-scoping dynamic-scoping + – Hradesh patel 877 views answer comment Share Follow Print See 1 comment 1 1 comment reply SAUMYA2019 commented Jan 18, 2019 reply Follow flag How is ans 992 by dynamic ..plz explain 0 0 replyShare Please log in or register to add a comment.
1 1 vote In Static Scoping, if a variable is not defined in the Local space, it is looked in Globle Space. In Dynamic Scoping, if a variable is not found in the Local space , it is looked in the place, where it recursive called. In Static gun() have local variable 'k' and pass updated value "6" ............ In fun(), there are no loval variable 'k' so in static dynamic it use GLOBLE variable and update then with k = i + 3 = 6+3 = 9 So in main() , print() print 9 . Hope you will understand. arya_stark answered Jul 3, 2018 arya_stark comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes for static scoping-9 6 9 dynamic scoping- 9 9 2 Anil Ji answered Jun 20, 2018 Anil Ji comment Share Follow 0 reply Please log in or register to add a comment.