Here is the Java Program of sum of corner elements in matrix in Java
Checkout:- ISC Specimen Papers for Class 12 Computer Practical 2020 Solution
Checkout:- Symmetric Matrix Program In Java
We are uploading these types of program. However, if you need fully compiled solution of any type of Java program then simply leave a comment below, we will help you at the earliest. 😊😊
import java.util.*;
class Sum_of_Corner_Elements
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number of Rows");
int r=sc.nextInt();
System.out.println("Enter the number of Columns");
int c=sc.nextInt();
int arr[][]=new int[r][c];
int sum=0;
System.out.println("Enter the elements of Matrix");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
arr[i][j]=sc.nextInt();
}
}
System.out.println("Input Matrix Is:");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println("");
}
sum=arr[0][0]+arr[0][r-1]+arr[r-1][0]+arr[r-1][r-1];
System.out.println("Sum of Corner Elements is="+sum);
}
}
------------
OUTPUT:-
------------
Enter the number of Rows
4
Enter the number of Columns
4
Enter the elements of Matrix
1
5
2
3
6
5
4
7
8
93
2
5
4
1
5
6
Input Matrix Is:
1 5 2 3
6 5 4 7
8 93 2 5
4 1 5 6
Sum of Corner Elements of Matrix is = 14
----------------------------------------
Checkout:- Bubble Sort Ascending Order Java Program
Checkout:- Bubble Sort In Descending Order Java
1 Comments
👌👌👌👍👍👍
ReplyDeleteJust write down your question to get the answer...