write a program in c language for the multiplication of two
matrices using pointers?
Answer Posted / syed fakheruddin ahmad
main()
{
int mat1[3][3] = {1,2,3,4,5,6,7,8,9};
int mat2[3][3] = {1,2,3,4,5,6,7,8,9};
int res[3][3];
int i,j,k;
for (i=0; i<3; i++)
for (j=0; j<3; j++)
res[i][j] = 0;
for (i=0; i<3; i++)
for (j=0; j<3; j++)
for (k=0; k<3; k++)
*(*(res + i) + j) += (*(*(mat1 + i) + k)) * (*(*(mat2 + k)
+ j));
for (i=0; i<3; i++)
{
for (j=0; j<3; j++)
printf ("%d\t", res[i][j]);
printf ("\n");
}
printf("\n");
}
| Is This Answer Correct ? | 100 Yes | 45 No |
Post New Answer View All Answers
code for replace tabs with equivalent number of blanks
What are the different types of pointers used in c language?
When should structures be passed by values or by references?
Explain what is the most efficient way to store flag values?
Explain what are bus errors, memory faults, and core dumps?
Which is the best website to learn c programming?
What is pass by reference in c?
How the c program is executed?
Why c is a mother language?
formula to convert 2500mmh2o into m3/hr
Why is #define used?
What are the __date__ and __time__ preprocessor commands?
How can you increase the size of a statically allocated array?
What is #include conio h?
How are structure passing and returning implemented?