Question: Draw a flowchart for this code package main; import java.util.Scanner; public class main { public static int[] locateSmallest(double array[][]) { double minimumElement = array[0][0]; int

Draw a flowchart for this code

package main;

import java.util.Scanner; public class main { public static int[] locateSmallest(double array[][]) { double minimumElement = array[0][0]; int arr[] = new int[2]; int i, j;

for (i = 0; i < array.length; i++) { for (j = 0; j < array.length; j++) { if (minimumElement > array[i][j]) { minimumElement = array[i][j]; arr[0] = i; arr[1] = j;

} } } return arr;

} public static void main(String[] args) { int row, column, i, j; Scanner s = new Scanner(System.in); System.out.print("Enter the number of rows: ");

row = s.nextInt(); System.out.print("Enter the number of columns: ");

column = s.nextInt();

double array[][] = new double[row][column];

System.out.println("Enter the array: "); System.out.print("Row 1 : "); for (i = 0; i < row; i++) {

for (j = 0; j < column; j++) { array[i][j] = s.nextDouble(); } System.out.print("Row " + (i + 2) + " : "); }

System.out.println("Elements of the array are: "); for (i = 0; i < row; i++) { for (j = 0; j < column; j++)

System.out.print(array[i][j] + " ");

System.out.println();

} int arr[] = locateSmallest(array); i = arr[0]; j = arr[1]; System.out.println(); System.out.println("The location of the smallest element is at (" + i + ", " + j + ")");

}

}



Step by Step Solution

3.32 Rating (149 Votes )

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 Programming Questions!