c++ continue versus break

前端 未结 6 988
抹茶落季
抹茶落季 2020-12-16 15:02

Which statement will be executed after \"continue\" or \"break\" ?

for(int i = 0; i < count; ++i)
 {
     // statement1                                            


        
6条回答
  •  醉梦人生
    2020-12-16 15:40

    Continue: It depends. The continue statement will execute the 'increment' part of the for-loop, then the 'test' part, and then decide whether to execute the next iteration or leave the loop. So it could be statement 2 or 3.

    Break: statement 3.

    Btw, is this homework?

提交回复
热议问题