write a program in c language for the multiplication of two
matrices using pointers?
Answer Posted / rohan
#include<stdio.h>
#define row 3
#define col 3
#define col2 3
int main()
{
int a[row][col],b[col][col2],c[row][col2],i,j,k;
printf("Enter the element of first matrix:->\n");
for(i=1;i<=row;i++)
{
for(j=1;j<=col;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("Enter the element of second matrix:->\n");
for(i=1;i<=col;i++)
{
for(j=1;j<=col2;j++)
{
scanf("%d",&b[i][j]);
}
}
/*printing of matrices*/
printf("\nMATRIX A\n");
for(i=1;i<=row;i++)
{
printf("\n");
for(j=1;j<=col;j++)
printf("%4d",a[i][j]);
}
printf("\nMATRIX B\n");
for(i=1;i<=col;i++)
{
printf("\n");
for(j=1;j<=col2;j++)
printf("%4d",b[i][j]);
}
/*multiplication*/
printf("\n\n");
for(i=1;i<=row;i++)
{
for(j=1;j<=col2;j++)
{
c[i][j]=0;
for(k=1;k<=col;k++)
c[i][j]=(c[i][j])+(a[i][k])*(b[k][j]);
}
}
/*printig of multiplication result*/
printf("MULTIPLICATION OF MATRIX A AND MATRIX B");
for(i=1;i<=row;i++)
{
printf("\n");
for(j=1;j<=col2;j++)
{
printf("%4d",c[i][j]);
}
}
printf("\n\n");
return 0;
}
| Is This Answer Correct ? | 7 Yes | 7 No |
Post New Answer View All Answers
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
how many key words availabel in c a) 28 b) 31 c) 32
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
Can we change the value of #define in c?
When the macros gets expanded?
The __________ attribute is used to announce variables based on definitions of columns in a table?
What is integer constants?
Explain logical errors? Compare with syntax errors.
What is the use of a semicolon (;) at the end of every program statement?
show how link list can be used to repersent the following polynomial i) 5x+2
can we change the default calling convention in c if yes than how.........?
Is sizeof a keyword in c?
What is a substring in c?
Why do we use int main instead of void main in c?
Explain the advantages of using macro in c language?