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
What oops means?
What is the difference between far and near in c?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
while initialization of array why we use a[][2] why not a[2][]...?
How to write c functions that modify head pointer of a linked list?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What is #line?
Linked lists -- can you tell me how to check whether a linked list is circular?
How important is structure in life?
Can a pointer point to null?
What is selection sort in c?
What is scope and lifetime of a variable in c?
Is calloc better than malloc?
What is a shell structure examples?
In C programming, how do you insert quote characters (‘ and “) into the output screen?