2 votes 2 votes saumya mishra asked Aug 27, 2017 saumya mishra 473 views answer comment Share Follow See 1 comment See all 1 1 comment reply saxena0612 commented Aug 27, 2017 reply Follow Share Answer is C After 2 it won't print anything due to the fact that after printing it calls the function in increment part of for loop and function will return 1. now after it again calls the function in condition part and it will return 0 and thus condition becomes false. Loop will terminate.It's a much similar scenario where we use true and false inside while construct.It's uncommon in for because we do increment and decrement in construct itself. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes C is right answer hem chandra joshi answered Aug 27, 2017 hem chandra joshi comment Share Follow See all 2 Comments See all 2 2 Comments reply saumya mishra commented Aug 27, 2017 reply Follow Share Yes the answer is c How can a function stop after we print 2 can u please explain it? 0 votes 0 votes shivangi5 commented Aug 28, 2017 reply Follow Share The sequence of function calls from main function in the loop will be as follows: Initialization, condition checking, Printf() statement, Increment then again condition checking,Printf() statement,Increment until function call in Condition checking gets 0 as return value. Now after we printed the value as 2 the function would stop since value at the Increment part would become 1 and at test condition part it becomes 0.("return num--" uses post-decrement operator) . This would behave as a infinite loop when we could have nonzero constant in the condition checking part. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes answer is option c bharti answered Aug 27, 2017 bharti comment Share Follow See all 0 reply Please log in or register to add a comment.