For Loops and stopping conditions

前端 未结 4 1775
孤城傲影
孤城傲影 2021-01-29 14:14

Can anyone explain why the answers are what they are please? The first one i guess its because the stopping condition is already reached so it skips the statement but question 1

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-29 14:51

    The first will produce no output as the for loop body is never run (assuming that the print line is within the for loop). The second appears to do nothing in the for loop and just prints the value of n after the loop. Which would be 0 as it has just failed a test for being greater than 0.

提交回复
热议问题