0 0 votes void abc() { auto int a; static int s; a=s++; printf("%d%d",a,s); if(a<=2) abc(); printf("%d%d",a,s); } void main() { abc(); abc(); } how many times printf will execute?? Programming in C + – saipriyab 1.9k views answer comment Share Follow Print See all 10 Comments 10 10 Comments reply SHUBHAM SHASTRI commented Nov 24, 2017 reply Follow flag 4 times ?? 0 0 replyShare hs_yadav commented Nov 24, 2017 i edited by hs_yadav Nov 24, 2017 reply Follow flag i think o/p:- (0,1) (1,2) (2,3) (3,4) .... (3,4) (2,4) (1,4) (0,4) (4,5) (4,5) (10 times) ????? 0 0 replyShare saipriyab commented Nov 24, 2017 reply Follow flag I got 8 times (0,1) (1,2) (2,3) (3,4) (3,4) (2,4) (1,4) (0,4) 0 0 replyShare saipriyab commented Nov 24, 2017 reply Follow flag @hs_yadav how 10 times how (4,5) (4,5) can u explain??? 0 0 replyShare joshi_nitish commented Nov 24, 2017 reply Follow flag yes it would be 10 times, 8 times on 1st call to abc(); and 2 times on 2nd call to abc(); 0 0 replyShare Red_devil commented Nov 24, 2017 reply Follow flag 10 times..because the second abc() will also execute it 2 times 0 0 replyShare SHUBHAM SHASTRI commented Nov 24, 2017 reply Follow flag how 1st one goes 8 times ...i didnt get 0 0 replyShare SHUBHAM SHASTRI commented Nov 24, 2017 reply Follow flag oh! ..i got it... 0 0 replyShare hs_yadav commented Nov 24, 2017 reply Follow flag @ saipriyab after the completion of first abc(); s=4 after the second call oof abc(); a=s++(a=4) s=5) and print(4,5) then a<=2 print(4,5)..... 1 1 replyShare saipriyab commented Nov 24, 2017 reply Follow flag yes I got it 1 1 replyShare Please log in or register to add a comment.
0 0 votes o/p 0,1 1,2 2,3 3,4 3,4 2,4 1,4 0,4 4,5 4,5 reason is static variable initialize only once . Nitesh Choudhary answered Nov 24, 2017 Nitesh Choudhary comment Share Follow See all 2 Comments 2 2 Comments reply abhishek tiwary commented Nov 25, 2017 reply Follow flag after 3,4 how the value of a get decremented?? 0 0 replyShare abhishek tiwary commented Nov 25, 2017 reply Follow flag ok i got it 0 0 replyShare Please log in or register to add a comment.