Posted by: Sourav | May 14, 2015

Matrix Multiplication in C


#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,k;
float a[3][4],b[4][2],c[3][2];
clrscr();
for(n=0;n<3;n++)
{
scanf(“%f%f%f%f”,&a[n][0],&a[n][1],&a[n][2],&a[n][3]);
}
for(n=0;n<3;n++)
{
printf(“%f\t%f\t%f\t%f\n”,a[n][0],a[n][1],a[n][2],a[n][3]);
}
for(n=0;n<4;n++)
{
scanf(“%f%f”,&b[n][0],&b[n][1]);
}

for(n=0;n<4;n++)
{
printf(“%f\t%f\n”,b[n][0],b[n][1]);
}

for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
{
c[j][i]=0;
for(k=0;k<4;k++)
{
c[j][i]=c[j][i]+a[j][k]*b[k][i];
}
}
}
for(n=0;n<3;n++)
{
printf(“%.2f\t%.22f\n”,c[n][0],c[n][1]);
}

getch();
}

 

 

 

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

Categories

%d bloggers like this: