+ 1

How to break an infinite loop

15th Jun 2018, 7:49 AM
Ayushman Bansal
Ayushman Bansal - avatar
4 odpowiedzi
+ 6
Use the 'break;' keyword. For example: int a = 0; while (true){ a++; if(a==7) break; }
15th Jun 2018, 7:52 AM
Alexandru Turculet
Alexandru Turculet - avatar
+ 5
PRAMOD JANA it would be an infinite loop without the break
15th Jun 2018, 8:28 AM
Alexandru Turculet
Alexandru Turculet - avatar
0
we can call this infinite loop int a=0; while (true) { printf ("infinite "); }
15th Jun 2018, 8:25 AM
PRAMOD JANA
PRAMOD JANA - avatar
- 1
the example which you have given above is not an infinite loop
15th Jun 2018, 8:22 AM
PRAMOD JANA
PRAMOD JANA - avatar