Question
This is a C program .. can you correct this #include int main(void) { int c, d, p, q, m, n, k, tot = 0;
This is a C program .. can you correct this
#include
int main(void) { int c, d, p, q, m, n, k, tot = 0; int fst[10][10], sec[10][10], mul[10][10];
printf(" Please insert the number of rows and columns for first matrix "); scanf("%d%d", &m, &n);
printf(" Insert your matrix elements : "); for (c = 0; c < m; c++) for (d = 0; d < n; d++) scanf("%d", &fst[c][d]); printf(" Please insert the number of rows and columns for second matrix "); scanf(" %d %d", &p, &q);
if (n != p) printf(" Your given matrices cannot be multiplied with each other. "); else { printf(" Insert your elements for second matrix "); for (c = 0; c < p; c++) for (d = 0; d < q; d++) scanf("%d", &sec[c][d] );
for (c = 0; c < m; c++) { for (d = 0; d < q; d++) { for (k = 0; k < p; k++) { tot = tot + fst[c][k] * sec[k][d]; } mul[c][d] = tot; tot = 0; } } // computing the transpose for (int i = 0; i < r; ++i) for (int j = 0; j < c; ++j) { transpose[j][i] = a[i][j]; } printf(" The result of matrix multiplication or product of the matrices is: "); for (c = 0; c < m; c++) { for (d = 0; d < q; d++) printf("%d \t", mul[c][d] ); printf(" "); } } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started