write a program in c language for the multiplication of two
matrices using pointers?
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,i,j,k;
int a[38][38],b[38][38],p[38][38];
printf("\nEnter the number of rows and coloumns ");
scanf("%d %d",&n,&m);
printf("\nEnter the elements of first matrix ");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",(*(a+i)+j));
}
}
printf("\nMatrix is ");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d",*(*(a+i)+j));
printf("\t");
}
}
printf("\nEnter the elements of second matrix ");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",(*(b+i)+j));
}
}
printf("\nMatrix is ");
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d",*(*(b+i)+j));
printf("\t");
}
}
printf("\nAfter multiplication ");
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
p[i][j]=0;
for(k=0;k<n;k++)
{
p[i][j]+=a[i][k]*b[k][j];
}
}
}
for(i=0;i<n;i++)
{
printf("\n");
for(j=0;j<m;j++)
{
printf("%d",*(*(p+i)+j));
printf("\t");
}
}
getch();
}
| Is This Answer Correct ? | 35 Yes | 14 No |
Post New Answer View All Answers
Function calling procedures? and their differences? Why should one go for Call by Reference?
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
How important is structure in life?
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
Write a program to check prime number in c programming?
Why is main function so important?
Why c is called free form language?
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
Explain how to reverse singly link list.
Explain how do I determine whether a character is numeric, alphabetic, and so on?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
What is the purpose of the statement: strcat (S2, S1)?
What is pointers in c?
What is wild pointer in c with example?