03) Write a program to read array A(4,4) and find : 1. The average of the second column. 2. Print even numbers under the main diagonal 3. Print negative numbers
![03) Write a program to read array A(4,4) and find:
1. The average of the second column.
2. Print even numbers under the main diagonal
3. Print negative numbers](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0807fd1d-9467-451e-802b-b8f2cb649220%2Febfd171f-90b9-4b3f-bbdc-b87e4ca0d69c%2Fqv4ai5_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
//Java Program for Average of Array Elements
import java.util.Scanner;
class javaExample
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int i,j,row,col;
float sum=0,average;
System.out.println("Enter the number of rows:");
row = sc.nextInt();
System.out.println("Enter the number of columns:");
col = sc.nextInt();
int[][] mat = new int[row][col];
System.out.println("Enter the elements of the matrix") ;
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
mat[i][j] = sc.nextInt();
}
}
System.out.println("The elements of the matrix") ;
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
System.out.print(mat[i][j]+"\t");
}
System.out.println("");
}
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
sum = sum + mat[i][j];
}
}
average=sum/(row*col);
System.out.printf("AVERAGE of the elements of the matrix = %.2f",average) ;
}
}
Output:
Enter the number of rows:3
Enter the number of columns:3
Enter the elements of the matrix
56
63
53
45
78
89
56
45
56
The elements of the matrix
56 63 53
45 78 89
56 45 56
AVERAGE of the elements of the matrix = 60.11
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)