Welcome to Westonci.ca, where your questions are met with accurate answers from a community of experts and enthusiasts. Connect with a community of experts ready to provide precise solutions to your questions quickly and accurately. Experience the convenience of finding accurate answers to your questions from knowledgeable experts on our platform.

Question: In a letter to the editor of CACM, Rubin (1987) uses the following code segment as evidence that the readability of some code with gotos is better than the equivalent code without gotos. This code finds the first row of an n by n integer matrix named x that has nothing but zero values.
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++)
if (x[i][j] != 0)
goto reject;
println ('First all-zero row is:', i);
break;
reject:
}
Rewrite this code without gotos in one of the following languages: C, C++, Java, or C#. Compare the readability of your code to that of the example code

For Help: https://www.chegg.com/homework-help/questions-and-answers/5-letter-editor-cacm-rubin-1987-uses-following-code-segment-evidence-readability-code-goto-q9138435
https://www.chegg.com/homework-help/questions-and-answers/letter-editor-cacm-rubin-1987-uses-following-code-segment-evidence-readability-code-gotos--q49180398

Sagot :

Answer:

C++

for (i = 1; i <= n; i++) {

flag = 1;

for (j = 1; j <= n; j++)

if (x[i][j] <> 0) {

flag = 0;

break;

}

if (flag == 1) {

printf ("First all zero row is: %d\n", i);

break;

}

}