+ 1

Difference between Break and continue statement?

7th May 2019, 1:57 PM
Vijith Krishnan S
Vijith Krishnan S - avatar
5 ответов
+ 9
Break: Break keyword is used to transfer control of loop outside the loop. For example:- for(i=0;i<5;i++) { if(i==3) break; else printf("%d",i); } It will print number from 0 to 2 and when value of i will be 3 then loop terminates. Continue: continue keyword is used to skip one number for example:- for(i=0;i<5;i++) { if(i==3) continue; else printf("%d",i); } It will print number from 0 to 5 except 3.
7th May 2019, 11:30 PM
Yamin Mansuri
Yamin Mansuri - avatar
7th May 2019, 2:03 PM
Sneyder Barreto
Sneyder Barreto - avatar
+ 4
Break stops a for loop, continue goes to the next iteration in a for loop,
7th May 2019, 2:13 PM
Ahri Fox
Ahri Fox - avatar
0
in ruby, continue doesnt exist, but next does and it does the exact same thing as continue 😁
7th May 2019, 4:54 PM
Choe
Choe - avatar