From 2784c0e3ef40bd6a9e16a8c7b5523fb07a8a8c6c Mon Sep 17 00:00:00 2001 From: Ankit Raj <85407190+Ankit-5087@users.noreply.github.com> Date: Sat, 15 Oct 2022 18:29:43 +0530 Subject: [PATCH] Create SumOfDiagArray It is a java based code to find the sum of the diagonal of a matrix. --- SumOfDiagArray | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 SumOfDiagArray diff --git a/SumOfDiagArray b/SumOfDiagArray new file mode 100644 index 0000000..c0cbcf6 --- /dev/null +++ b/SumOfDiagArray @@ -0,0 +1,49 @@ +import java.util.Scanner; +class array2d_diag +{ + public static void main (String args[]) + { + Scanner sc = new Scanner(System.in); + System.out.println("matrix row dimensions :"); + int n =sc.nextInt(); + System.out.println("matrix column dimensions :"); + int m =sc.nextInt(); + int ar[][]= new int[n][m]; + int diag1=0;int diag2=0; + for(int i=0 ;i