// Matrix Multiplication Program
#include<stdio.h>
void main()
{
int c[2][2],i,a[2][2],b[2][2],j,k;
printf("Enter 5 numbers");
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
scanf("%d",&a[i][j]);
printf("Elements of array are a[%d][%d]=%d\n",i,j,a[i][j]);
}
}
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
scanf("%d",&b[i][j]);
printf("Elements of array are b[%d][%d]=%d\n",i,j,b[i][j]);
}
}
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
c[i][j]=0;
for(k=1;k<=2;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("\n ************************************************");
printf("\n The Final Output is: ");
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
printf("\nElements of array are c[%d][%d]=%d\n",i,j,c[i][j]);
}
}
}
#include<stdio.h>
void main()
{
int c[2][2],i,a[2][2],b[2][2],j,k;
printf("Enter 5 numbers");
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
scanf("%d",&a[i][j]);
printf("Elements of array are a[%d][%d]=%d\n",i,j,a[i][j]);
}
}
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
scanf("%d",&b[i][j]);
printf("Elements of array are b[%d][%d]=%d\n",i,j,b[i][j]);
}
}
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
c[i][j]=0;
for(k=1;k<=2;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("\n ************************************************");
printf("\n The Final Output is: ");
for(i=1;i<=2;i++)
{
for(j=1;j<=2;j++)
{
printf("\nElements of array are c[%d][%d]=%d\n",i,j,c[i][j]);
}
}
}
I liked this post because it was very informative MBBS IN UKRAINE
ReplyDelete