2 votes 2 votes Question: mohitbawankar asked Jan 6, 2018 mohitbawankar 1.1k views answer comment Share Follow See all 9 Comments See all 9 9 Comments reply Show 6 previous comments mohitbawankar commented Jan 6, 2018 reply Follow Share see my comments its given by made easy 0 votes 0 votes gauravkc commented Jan 6, 2018 reply Follow Share But that doesn't explain the case in my code. Then it should be 15 55 60 55 Also, addresses are different for both. 0 votes 0 votes gauravkc commented Jan 6, 2018 reply Follow Share @joshi_nitish @Anu007 @hs_yadav @Ashwin Kulkarni Even if variable name is same, with multiple static declarations in different functions, is the scope of variable limited to repeated calls for same function only? 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes I Think This will make you more clear.... Ans is ;- 15 20 15 15 Manis answered Jan 6, 2018 • edited Jan 6, 2018 by Manis Manis comment Share Follow See all 2 Comments See all 2 2 Comments reply mohitbawankar commented Jan 6, 2018 reply Follow Share ans is 15 20 15 15 0 votes 0 votes mohitbawankar commented Jan 6, 2018 reply Follow Share Solution : (d) • print 1( ): x = 10 + 5 = 15; since the variable is of static storage class, hence it will retain its value between different function calls. • print 1( ): x = 15 + 5 = 20; since it has retained its value 15. • print 2( ): x is defined again inside the function and hence will print, x = x + 5 = 10 + 5 = 15. Again when the function will be called, x = 10 + 5 = 15. Here second time also x = 10 will be there because it is not initialized at the time of definition. Hence output 15, 20, 15, 15. 0 votes 0 votes Please log in or register to add a comment.