0
Give example of break statement outside of loop that cause error.
2 odpowiedzi
+ 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
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