C Language problem I think it will use malloc or calloc Matr

C Language problem, I think it will use malloc or calloc

Matrix operations with pointers

Write a program that uses a function matrix_addition() to add two matrices and put the result into a third matrix.

The function takes three matrices and a row and a column argument. The first two arguments are the matrices to be added, the third is the matrix that will take the result. The rows/columns arguments make sure that the function \"knows\" what the dimensions of the matrices are.

Thanks, in advance

Solution

#include <stdio.h>

int main()
{
int NoofRows, NoofColumns, c, d, firstMatrix[10][10], secondMatrix[10][10], ResultantMatrix[10][10];

printf(\"Enter the number of rows and columns of matrix\ \");
scanf(\"%d%d\", &NoofRows, &NoofColumns);
printf(\"Enter the elements of first matrix\ \");

for (c = 0; c < NoofRows; c++)
for (d = 0; d < NoofColumns; d++)
scanf(\"%d\", &firstMatrix[c][d]);

printf(\"Enter the elements of second matrix\ \");

for (c = 0; c < NoofRows; c++)
for (d = 0 ; d < NoofColumns; d++)
scanf(\"%d\", &secondMatrix[c][d]);

printf(\"Sum of entered matrices:-\ \");

for (c = 0; c < NoofRows; c++) {
for (d = 0 ; d < NoofColumns; d++) {
ResultantMatrix[c][d] = firstMatrix[c][d] + secondMatrix[c][d];
printf(\"%d\\t\", ResultantMatrix[c][d]);
}
printf(\"\ \");
}

return 0;
}

C Language problem, I think it will use malloc or calloc Matrix operations with pointers Write a program that uses a function matrix_addition() to add two matri

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site