0

Give example of break statement outside of loop that cause error.

11th Jul 2016, 10:51 AM
Rupam Das
Rupam Das - avatar
2 ответов
+ 1
as i know it certainly dosent give u an error but a warning. suppose: i=2; while(i) { cout<<i; i--; } if(i==0) { break; cout<<"warning"; } in this block of code while will iterate till i > 0 then it will go to if which is true but before printing warning it will break it hence giving a warning : unreachable code
12th Jul 2016, 2:27 PM
Rishabh Abhani
Rishabh Abhani - avatar
0
@Rishabh Abhani I think you are lost bruh. C language section is 10 miles north from here. In python, typing break outside a loop causes a syntax error. Just type in break in console. Syntax error: 'break' outside loop
12th Jul 2016, 10:35 PM
Gershon Fosu
Gershon Fosu - avatar