Using a Break statement does not necessarily make your codes logic inconsistent and breaks are often useful to improve the readability of your code. But in answer to your question this can be achieved by utilizing while loops and logical boolean operators. A modified version of your code is below, I have tried to modify it as little as possible so you can still see your code within the example. There are a few logical errors in your code that I have left in the example below that you might want to look into. In particular the line below will print "is odd" when in fact the number would be even. If you where wanting to check if the number arrays[0][first] is odd then the following if statement would be needed if (arrays[0][first] % 2 != 0) instead of if (arrays[0][first] % 2 == 0).
Logical Error
if (arrays[0][first] % 2 == 0) { cout << arrays[0][first] << " is odd " << endl;
This is the code without using breaks.
bool swapped = true; if (arrays[0][first] % 2 == 0) { cout << arrays[0][first] << " is odd " << endl; int i = 1; while ( (i < arraycount) && swapped) { int j = 1; bool if_odd = true; while ((j < arrays[i][0] + 1) && if_odd) { if (arrays[i][j] % 2 != 0) { int temp = arrays[i][j]; cout << "Array #" << 1 << " value " << arrays[0][first] << " swapped with " << "Array #" << i << " value " << temp; arrays[i][j] = arrays[0][first]; arrays[0][first] = temp; swapped = false; if_odd = false; } j++; } i++; } }
swappedanint, when it works as abool?for ( initial; usual-condition && break-condition; stepper) {...}