How to use goto to break a nested loop
c++, for-loop, goto
Solution
Like this:
int i,j;
for(i = 0; i < 9; i++)
{
for(j = 0; j < 9; j++)
{
//cout << " " << Matrix[i][j];
//cout << "i: " << i << endl;
if(Matrix[i][j] == 0)
{
//temp = 10;
goto end;
//break;
}
}
}
end:
cout << i << " " << j << endl;
Problem
How can I use a "goto" statement to break out of a loop ``` for(i = 0; (i < 9); i++) { for(j = 0; j < 9; j++) { //cout << " " << Matrix[i][j]; //cout << "i: " << i << endl; if(Matrix[i][j] == 0) { //temp = 10; [goto] ; //break; } } } ``` I wanted to keep the values at which i and j were when I left the nested for loop. How can I use a goto statement for that?