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


Please Help Members By Posting Answers For Below Questions

What oops means?

588


What is the difference between far and near in c?

605


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

640


while initialization of array why we use a[][2] why not a[2][]...?

1870


How to write c functions that modify head pointer of a linked list?

548






What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?

909


What is #line?

615


Linked lists -- can you tell me how to check whether a linked list is circular?

648


How important is structure in life?

595


Can a pointer point to null?

594


What is selection sort in c?

613


What is scope and lifetime of a variable in c?

582


Is calloc better than malloc?

584


What is a shell structure examples?

596


In C programming, how do you insert quote characters (‘ and “) into the output screen?

899