Question: Rubin [Rub87] used the following example (rewritten here in C) to argue in favor of a goto statement: The intent of the code is to

Rubin [Rub87] used the following example (rewritten here in C) to argue in favor of a goto statement:

int first_zero_row = -1; int i, j; /* none */ for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (A[i] [j]) goto next; } first_zero_row = i; break; next: ; }

The intent of the code is to find the first all-zero row, if any, of an n × n matrix. Do you find the example convincing? Is there a good structured alternative in C? In any language?

int first_zero_row = -1; int i, j; /* none */ for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (A[i] [j]) goto next; } first_zero_row = i; break; next: ; }

Step by Step Solution

3.28 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a possible solution in C If C a... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Language Pragmatics Questions!