by using c programming i must wright this codes.help me please. You should want
ID: 3811012 • Letter: B
Question
by using c programming i must wright this codes.help me please.
You should want the number of row and the number of column from the user for two dimensional matrix. Create two dimensional matrix inside the main function according to matrix dimension. Using Matrix_read function, want all the members of matrix from the user while writing (row, column) information. Using Matrix_write function, write the matrix member as matrix form onto the computer screen. Inside the main function, create new matrix which should be transpose of original matrix and constitute the member of transpose matrix using Matrix transpose function. Using Matrix_mult function, obtain new matrix which is equal to original matrix multiplied by transpose of original matrix. (for example new_matrix = A*A^T). You have to calculate matrix dimension of new matrix then create matrix inside the Matrix_mult function to keep result of A*A^T. Then call Matrix write function inside the Matrix_mult function to show final matrix result onto computer screen. You have to create some functions below: 1) Matrix_read (taking matrix member from user) 2) Matrix-write (writing matrix member as matrix form onto the computer screen) Matrix_transpose (using original function constituting the member of transpose matrix) 4) Matrix_mult (using original and transpose matrix obtaining multiplication for original and transpose matrix then writing the results onto computer screen)Explanation / Answer
I have written the code for reading the martrix, printing it, multilying it and also transpose of matrix.
#include <stdio.h>
int main()
{
int m, n, p, q, c, d, k, sum = 0;
int first[10][10], second[10][10], multiply[10][10],transpose[10][10];
printf("Enter the number of rows and columns of first matrix ");
scanf("%d%d", &m, &n);
printf("Enter the elements of first matrix ");
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf("%d", &first[c][d]);
printf("Enter the number of rows and columns of second matrix ");
scanf("%d%d", &p, &q);
if (n != p)
printf("Matrices with entered orders can't be multiplied with each other. ");
else
{
printf("Enter the elements of second matrix ");
for (c = 0; c < p; c++)
for (d = 0; d < q; d++)
scanf("%d", &second[c][d]);
for (c = 0; c < m; c++) {
for (d = 0; d < q; d++) {
for (k = 0; k < p; k++) {
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
sum = 0;
}
}
printf("The first matrix is ");
for (c = 0; c < p; c++){
for (d = 0; d < q; d++)
printf("%d ", first[c][d]);
printf(" ");
}
printf("The first matrix is ");
for (c = 0; c < p; c++){
for (d = 0; d < q; d++)
printf("%d ", second[c][d]);
printf(" ");
}
printf("Product of entered matrices:- ");
for (c = 0; c < m; c++) {
for (d = 0; d < q; d++)
printf("%d ", multiply[c][d]);
printf(" ");
}
}
for (c = 0; c < m; c++)
for( d = 0 ; d < n ; d++ )
transpose[d][c] = matrix[c][d];
printf("Transpose of entered matrix :- ");
for (c = 0; c < n; c++) {
for (d = 0; d < m; d++)
printf("%d ",transpose[c][d]);
printf(" ");
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.