The program below is designed to locate the first all-zero row of a n n matrix if any exist. Is this the proper solution to the problem, and is there another suitable structured way to this code in C, or in any language?
Code:
int first_zero_row = -1; /* none */
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (A[i][j]) goto next;
}
first_zero_row = i;
break;
next: ;
}
I'm attempting to learn more about goto statements and their acceptable uses/alternatives. Any assistance is much appreciated!