Question

# Print Product of elements of each row and column in integer matrix.

```				```
Enter size of integer Matrix:
4
Enter Elements in Matrix:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Elements in Matrix:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
The product of elements of row 1 is=24
The product of elements of row 2 is=1680
The product of elements of row 3 is=11880
The product of elements of row 4 is=43680
The product of elements of Column 1 is=585
The product of elements of Column 2 is=1680
The product of elements of Column 3 is=3465
The product of elements of Column 4 is=6144
```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;
public class ProductOfEachRowAndColumnOfSquareMatrix
{
public static void main()
{
int[ ][ ] arr;
int size;
long product;
int i,j;
Scanner sc=new Scanner(System.in);
System.out.println("Enter size of integer Matrix:");
size=sc.nextInt();
arr=new int[size][size];

System.out.println("Enter Elements in Matrix:");
for(i=0;i< size;i++)
{
for(j=0;j< size;j++)
{
arr[i][j]=sc.nextInt();
}
}
System.out.println("Elements in Matrix:");
for(i=0;i< size;i++)
{
for(j=0;j< size;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
for(i=0;i< size;i++)
{
product=1;
for(j=0;j< size;j++)
{
product =product*arr[i][j];
}
System.out.println("The product of elements of row "+(i+1)+" is="+product);

}
for(j=0;j< size;j++)
{
product=1;
for(i=0;i< size;i++)
{
product =product*arr[i][j];
}
System.out.println("The product of elements of Column "+(j+1)+" is="+product);

}

}
}

```
```

Sale

50
Sale

150
Sale

200
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50
Sale

50