Posted by : ANIMESH SHAW Saturday, 8 October 2011

#include<stdio.h>
main()
{
int a[20][20],b[20][20],c[20][20],r1,c1,c2,r2,i,j,k;
printf(“\tEnter the row and coloumn size For matrix1\n”);
scanf(“%d%d”,&r1,&c1);
printf(“\tEnter the row and coloumn size For  matrix2\n”);
scanf(“%d%d”,&r2,&c2);
if (c1!=r2)
{
printf(“\tOppssss...The Coloumn size of Matrix1 not equal to row size of Matrix2\n\tMultiplication impossible/n”);
}
else
{
printf(“\tEnter elemnts of matrix1\n”);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“\tEnter elements of matrix2\n”);
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
c[i][j]=0;
for(k=0;k<c1;k++)
{
c[i][j]+=a[i][k]*b[k][j];
}
}
}
printf(“\tYes...!! Product Matrix…\n”);
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
printf(“\t%d\t”,c[i][j]);
}
printf(“\n”);
}
}
}





OUTPUT:



Enter the row and coloumn size of matrix1
3
3
Enter the row and coloumn size of matrix2
3
3
Enter elemnts of matrix1
1
2
3
4
5
6
7
8
9

Enter elemnts of matrix2
9
8
7
6
5
4
3
2
1

Product Matrix…

30 24 18

84 69 54

138 114 90

Popular Post

Blog Archive

Total Pageviews

Sign In

Follow by Email

Powered by Blogger.

Like Us on Facebook

Search This Blog

Loading...

Indian Coder

- Copyright © Programming Mania -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -