break two loops

I am suffering from the problem please anyone help me
I have the following condition
j=0;
while(j<9){
for(i=0;i<10;i++){
//statements

if(condition){
//statements
}
}
for(k=0;k<10;k++){
//statements

if(condition){
//statements}
}
}
j++;
}
Now my Question is that i need a condition in both "if" that terminate the while loop but not exit the program
Chances are that the loop is better off in its own function. You can then use return.
bool valid = true;

j=0;
while(j<9){
for(i=0;i<10;i++){
//statements

if( valid = condition){
//statements
}
}
for(k=0;valid && k<10;k++){
//statements

if( valid = condition){
//statements}
}
}
if ( !valid ) break;

j++;
}
A nice and clean way to do that is to use a goto.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
j=0;
while(j<9)
{
    for(i=0;i<10;i++)
    {
        //statements
        if(condition)
        {
            //statements
            goto loop_exit;
        }
    }
    for(k=0;k<10;k++)
    {
         //statements
        if(condition)
        {
            //statements
            goto loop_exit;
        }
    }
    j++;
}
loop_exit:
// ... 
Topic archived. No new replies allowed.