0 votes 0 votes 15, 20, 25, 30 15, 20, 15, 20 15, 15, 15, 15 None of these User007 asked Jan 21, 2017 User007 440 views answer comment Share Follow See 1 comment See all 1 1 comment reply Tendua commented Jan 21, 2017 reply Follow Share 15, 20,15,15 i think. D 1 votes 1 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes According to me:none of these. My answer is 15,20,15,15 Lucky sunda answered Jan 21, 2017 • selected Jan 21, 2017 by Sushant Gokhale Lucky sunda comment Share Follow See all 2 Comments See all 2 2 Comments reply User007 commented Jan 21, 2017 reply Follow Share Yes, your solution is correct. Could you please explain it. 0 votes 0 votes Lucky sunda commented Jan 21, 2017 reply Follow Share The key point here is the line static int x; static keyword will store the variable x in static area, and therefore it will be initialised only once. That is when you execute the function first time then only this line will be executed, and in every other call, it will be skipped. now, the x in print1() and print2() are different. print1() //first time x will be created, and 15 will the final result of first execution. print1() //second time x is already created, and 20 will the final result of second execution. similarly try to execute print2().As it overwrites x=10, so everytime the result will be 15 only. 1 votes 1 votes Please log in or register to add a comment.