WAP in C for multiplication of two matrices?

#include<stdio.h>
#include<conio.h>
int main()
{
int a[2][3],b[3][2],c[2][2],i,j,k;
clrscr();
printf(“\nEnter the element of first matrix”);
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“\nEnter the element of second matrix”);
for(j=0;j<3;j++)
{
for(k=0;k<2;k++)
{
scanf(“%d”,&b[j][k]);
}
}
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
c[i][j]=0;
for(k=0;k<3;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf(“Multiplication is\n”);
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf(“\t%d”,c[i][j]);
}
printf(“\n”);
}
getch();
return(0);
}

Output :-

multiplymatrix

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s