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 is getch() function?

643


What does the && operator do in a program code?

690


What is meant by recursion?

628


Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

594


What is difference between class and structure?

564






What is wrong with this code?

689


How do I swap bytes?

626


Is c easier than java?

564


What is an array in c?

589


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

2787


In C language, a variable name cannot contain?

737


What do you mean by dynamic memory allocation in c?

644


Why do we need volatile in c?

739


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

599


How do you define a function?

579