Question: Can you correct these lines of this C code . Line 9 / Line 10 / Line 13 / Line 14 / Line 15 /

Can you correct these lines of this C code . Line 9 / Line 10 / Line 13 / Line 14 / Line 15 / Line 19 / Line 20 / Line 23 / Line 25 / Line 68

and show me the that the code is working

#include

int main(void)

{

// Declare variables

int c, d, p, q, m, n, k, tot = 0;

int fst[10][10], sec[10][10], mul[10][10], transpose[10][10];

}

printf(" Please insert the number of rows and columns for first matrix ");

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

// Read in the elements of the first matrix

printf(" Insert your matrix elements : ");

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

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

scanf("%d", &fst[c][d]);

// Read in the number of rows and columns for the second matrix

printf(" Please insert the number of rows and columns for second matrix ");

scanf(" %d %d", &p, &q);

// Check if the matrices can be multiplied

if (n != p)

printf(" Your given matrices cannot be multiplied with each other. ");

else

{

// Read in the elements of the second matrix

printf(" Insert your elements for second matrix ");

for (c = 0; c < p; c++)

for (d = 0; d < q; d++)

scanf("%d", &sec[c][d]);

// Multiply the matrices

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;

}

}

// Print the result of the matrix multiplication

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(" ");

}

// Compute the transpose of the product matrix

int r = q, c = m;

for (int i = 0; i < r; ++i)

for (int j = 0; j < c; ++j) {

transpose[j][i] = mul[i][j];

}

// Print the transpose of the product matrix

printf("The transpose of the product matrix is: ");

for (int i = 0; i < c; ++i) {

for (int j = 0; j < r; ++j)

printf("%d \t", transpose[i][j]);

printf(" ");

}

}

return 0;}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!