Question: package twoDArrays; import java.io.* ; public class RowSum { public static void main ( String[] args ) throws IOException { int [][] data = {{3,

package twoDArrays;

import java.io.* ;

public class RowSum {

public static void main ( String[] args ) throws IOException

{

int[][] data = {{3, 2, 5},{1, 4, 4, 8, 13},{9, 1, 0, 2}, {0, 2, 6, 3, -1, -8} };

// declare the sum

int sum;

// compute the sums for each row

for ( int row=0; row < data.length; row++)

{

// initialize the sum

sum = 0;

// compute the sum for this row

for ( int col=0; col < data[row].length; col++)

{

sum = sum +data[row][col];

}

// write the sum for this row

System.out.println( " for the row " + row + " sum is " + sum);

}

}}

Modify the program above so that it prints the array and then computes and prints the smallest element in each row.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!