Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 0 values. Here is the code in C.

include

int main(void)

{

int x[4][4] = {{0, 0, 0, 0},{0, 1, 2, 3}};

int n=4;

int i, j;

int r=-1;

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

for (j = 0; j < n; j++){

if (x[i][j] != 0){

goto reject;

}

}

r=i;

break;

}

reject: printf (" First all-zero row is: %d", r);

return 0;

}

Rewrite this code without gotos in any language of your choice.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

suggest a range of work sample exercises and design them

Answered: 1 week ago