Double Dimensional Array(Matrix) Program I (Maximum minimum element, sum, average)
Double Dimensional Array(Matrix) Program I…: solved Java program for ISC Class 11 Computer Science with complete BlueJ code, explanation and sample output.
Write a program to ask the user to input a double dimensional integer array and print the biggest(Maximum) and the smallest(Minimum) element of the array with its place in the array. Print the sum and the average of all the elements also.
import java.io.*;
class MinMaxDDA{
public static void main() throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter no. of rows");
int r=Integer.parseInt(br.readLine());
System.out.println("Enter no. of columns");
int c=Integer.parseInt(br.readLine());
int m[][]=new int[c][r];
for(int i=0;i<c;i++){
for(int j=0;j<r;j++){
System.out.println("Enter value for matrix");
m[i][j]=Integer.parseInt(br.readLine());
}
}
System.out.println("the matrix is:");
for(int i=0;i<c;i++){
for(int j=0;j<r;j++){
System.out.print(m[i][j]+" ");
}
System.out.println();
}
int x=m[0][0];
int y=m[0][0];
int r1=0,c1=0,r2=0,c2=0;
int sum=0;double avg=0.0;
for(int i=0;i<c;i++){
for(int j=0;j<r;j++){sum+=m[i][j];
if(m[i][j]<x){
x=m[i][j];
r1=i;
c1=j;
}
else if(m[i][j]>y){
y=m[i][j];
r2=i;
c2=j;
}
}
}
avg=(double)sum/(c*r);
System.out.println("The max value in matrix is "+y);
System.out.println("It is at"+r2 +" "+c2 +" index ");
System.out.println("The min value in matrix is "+x);
System.out.println("It is at"+r1 +" "+c1 +" index ");
System.out.println("The sum of all the elements is "+sum);
System.out.println("The average of the matrix is "+avg);
}
}Output:
Enter no. of rows
3
Enter no. of columns
3
Enter value for matrix
8
Enter value for matrix
7
Enter value for matrix
6
Enter value for matrix
4
Enter value for matrix
5
Enter value for matrix
3
Enter value for matrix
2
Enter value for matrix
1
Enter value for matrix
9
the matrix is:
8 7 6
4 5 3
2 1 9
The max value in matrix is 9
It is at 2 2 index
The min value in matrix is 1
It is at 2 1 index
The sum of all the elements is 45
The average of the matrix is 5.0
Related Posts
Continue learning with these related articles

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.

ISC Class 11 Computer Science Sample Paper 2026-27 with Solutions
A full 70-mark ISC Class 11 Computer Science sample paper for the 2026-27 annual exam: MCQs, number systems, propositional logic, logic gates, Java classes, arrays, strings, searching and sorting, and computing ethics, with complete worked solutions.