Checkout:- Program to sort non-boundary elements of matrix in Descending Order
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.*;
public class Sum_of_Rows
{
public static void main()
{
int s=0;
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];
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("");
}
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
s=s+arr[i][j];
}
System.out.println("Sum of Row "+i+"= "+s);
s=0;
}
}
}
-------------
OUTPUT:-
-------------
Enter the number of Rows
3
Enter the number of Columns
3
Enter the elements of Matrix
1
2
3
4
5
6
7
8
9
Input Matrix Is
1 2 3
4 5 6
7 8 9
Sum of Row 0 = 6
Sum of Row 1 = 15
Sum of Row 2 = 24
----------------
Checkout:- Sort Matrix in Ascending Order Java
0 Comments
Just write down your question to get the answer...