When a break statement is encountered in nested loops, it will only terminate the innermost loop and resume execution with the next statement after that loop. The outer loops will continue their execution.
Example:
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
if (i == 2 && j == 2) {
break; // Terminates the inner loop when i equals 2 and j equals 2
}
cout << i << "-" << j << " ";
}
}
// Output: 1-1 1-2 1-3 3-1 3-2 3-3