package Ex3SumDiagonal;
import java.util.Random;
public class Ex3SumDiagonal {
public static double sumMajorDiagonal(double[][] m) {
double sum = 0;
for (int i = 0; i < m.length; i++) {
sum += m[i][i];
}
return sum;
}
public static void main(String[] args) {
Random random = new Random();
final int SIZE = 4;
double[][] m = new double[SIZE][SIZE];
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
m[i][j] = 1 + random.nextDouble() * 19;
}
}
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
System.out.printf("%.2f ", m[i][j]);
}
System.out.println();
}
System.out.printf("\nThe sum of the major diagonal is %.2f\n", sumMajorDiagonal(m));
}
}

use java please Exercise 3 Sum the Major Diagonal of a Matrix Complete exercise 8.2 on...
Use the C programming language to complete
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
// Declare Global variables here.
void array_stats() {
// Insert your solution here.
}
#include <stdlib.h>
#include <time.h>
int main() {
// Simulate the test setup process.
srand( time( NULL ) );
for ( int i = 0; i < 32; i++ ) {
val[i] = rand();
}
val_count = rand();
val_mean = rand();
val_min = rand();
val_max = rand();
// Call submitted code.
array_stats();
// Display...