Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Matrices In this exercise you will write several functions that, operate on matr

ID: 3938038 • Letter: M

Question

Matrices In this exercise you will write several functions that, operate on matrices or two-dimensional arrays. For this exercise, we will restrict our attention to square. matrices-collections of numbers with the same number of columns and rows. You will place all the function prototypes in a header file named matrix.h with their definitions in a source file named matrix.c. You should test your functions by writing a driver program, but you need not hand it in. Write a function that takes two matrices and determines if the sum of all of the elements in matrix A is equal to the sum of all the elements in matrix B. Return 0 if the summation is equal and 1 if they are not equal. int sum Equal(int**A, int **B, int n); Write a function that takes two matrices and determines if they are equal (all of their elements are the same). If the matrices are equal, return 0. Return I if they are not equal. int is Equal(int **A, int **B, int n); Write a function to compute the sum of the elements along the diagonal of the matrix. Return the sum of the elements along the diagonal. int diagonal (int **A, int n); Write a function to compute the summation of matrix A and B. int.** surnMatrix(int. **A, int **B, int n); The product of two square n times n matrices: C = A times B The entries for C are: C_ij = sigma^n_k = 1 a_ikb_kj where 1 lessthanorequalto i, j lessthanorequalto n and is the (i, j)-th entry of the matrix C. Write the following function to compute the product of two n times n square matrices: int ** product(int **A, int **B, int n); Bonus Name the files, bonus.c and bonus.h char highestFreq(char *str)- this function should return the highest frequency character c in the string. For example, a call to this function with the string "Hello World", would return "1"

Explanation / Answer

d))))))))))

#include<stdio.h>

int main(){

int a[10][10],b[10][10]i,j,k,l,sum=0,sum1,m,n;

printf(" Enter the row and column of matrix: ");

scanf("%d %d",&m,&n);

printf(" Enter the elements of matrix: ");

  for(i=0;i<m;i++)

      for(j=0;j<n;j++)

           scanf("%d",&a[i][j]);

printf(" The matrix is ");

  for(i=0;i<m;i++){

      printf(" ");

      for(j=0;j<m;j++){

      printf("%d ",a[i][j]);

      }

}

for(i=0;i<m;i++){

     for(j=0;j<n;j++){

          if(i==j)

              sum=sum+a[i][j];

     }

}

printf(" Sum of the diagonal elements of a matrix is: %d",sum);

printf(" Enter the row and column of matrix2: ");

scanf("%d %d",&k,&l);

printf(" Enter the elements of matrix2: ");

  for(i=0;i<k;i++)

      for(j=0;j<l;j++)

           scanf("%d",&b[i][j]);

printf(" The matrix2 is ");

for(i=0;i<m;i++){

      printf(" ");

      for(j=0;j<m;j++){

      printf("%d ",b[i][j]);

      }

}

for(i=0;i<k;i++){

     for(j=0;j<l;j++){

          if(i==j)

              sum1=sum1+b[i][j];

     }

}

printf(" Sum of the diagonal elements of a matrix is: %d",sum1);

if(sum==sum1)

return 0

else

return 1

}