c++ continue versus break

前端 未结 6 1026
抹茶落季
抹茶落季 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:45

    statement2 will execute after the continue, given that the loop was not in the last iteration.

    statement3 will execute after the break.

    'continue' (as the name suggests) continues the loop, while skipping the rest of the statements in the current iteration.

    'break' breaks and exits from the loop.

提交回复
热议问题