Completely Solved C, C++ Programs Assignment.

 Quick Search Database Videos Tutorials Ebooks Forums FAQ Aboutus Household Industrial Manufacturing Service Shopping Transportation

### C Programs to multiply two Matrices

 Filed Under: Sample C program

Problem 57. C Programs to multiply two Matrices
#include<stdio.h>
#include<conio.h>
main( )
{
int
a[10][10],b[10][10],c[10],[10],i,j,m,n,p,q,
k;
clrscr( );
printf(“enter the size of first matrices”);
scanf(“%d%d’,&m,&n);
printf(“enter the size of second matrix”);
scanf(“%d%d’,&p,&q);
if(n==p)
{
printf(“enter first matrices elements”);
for(i=1;i<m;i++)
for(j=1;j<n;j++)
scanf(“%d”,&a[i][j]);
printf(“enter second matrix elements”);
for(i=1;i<p;i++)
for(j=1;j<q;j++)
scanf(“%d”,&b[i][j]);
for(i=1;i<m;i++)
for(j=1;j<n;j++)
{
c[i][j]=0;
for(k=1;k<n;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
printf(“the multiplication matrix is”);
for(i=1;i<m;i++)
{
for(j=1;j<n;j++)
print(“%2d”,c[i][j]);
printf(“n”);
}
}
else
printf(“multiplication is not possible”);
getch( );
}

C compiler: gcc 4.1.2

Back to main directory: Sample C Program | Software Practical | Solved C Assignment