#include <stdio.h> int main() { int n; printf("write the size of the matrix\n"); scanf("%d", &n); int array1[n][n]; int array2[n][n]; int sum12[n][n]; int dif12[n][n]; int mult1=1; int mult2=1; printf("Fill the first matrix\n"); printf("Fill the first raw\n"); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ scanf("%d", &array1[i][j]); } if (i<n-1){ printf("Next raw\n"); } } printf("The first matrix is:\n"); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ printf("%d ", array1[i][j]); } printf("\n"); } printf("Fill the second matrix\n"); printf("Fill the first raw\n"); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ scanf("%d", &array2[i][j]); } if (i<n-1){ printf("Next raw\n"); } } printf("The second matrix is:\n"); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ printf("%d ", array2[i][j]); } printf("\n"); } printf("The sum of matrixes is is:\n"); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ sum12[i][j] = array2[i][j] + array1[i][j]; } } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ printf("%d ", sum12[i][j]); } printf("\n"); } printf("The diferrence of matrixes is :\n"); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ dif12[i][j] = array1[i][j] - array2[i][j]; } } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ printf("%d ", dif12[i][j]); } printf("\n"); } printf("The sum of the multiplication of elements on the diagonals for the first matrix is:\n"); for(int i = 0; i < n; i++){ mult1 = mult1*array1[i][i]; mult2 = mult2*array1[n-1-i][n-1-i]; } printf("%d\n", mult1+mult2); mult1=1; mult2=1; printf("The sum of the multiplication of elements on the diagonals for the second matrix is:\n"); for(int i = 0; i < n; i++){ mult1 = mult1 * array2[i][i]; mult2 = mult2 * array2[n-1-i][n-1-i]; } printf("%d", mult1 + mult2); return 0; }