Sei sulla pagina 1di 1

/*program to perform the multiplication of two matrices*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a[5][5],b[5][5],m,n,x,y,i,j,k,c=0;
printf("enter the no.of rows and columns for matrix a:");
scanf("%d%d",&m,&n);
printf("enter the no.of rows and columns for matrix b:");
scanf("%d%d",&x,&y);
if(n!=x)
printf("the matrix multiplication is nit possible\n");
else
{
printf("enter the elemnts for the matrix a:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
]
printf("\nenter the elements for the matrix b:\n");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<y;j++)
{
for(k=0;k<n;k++)
{
c=c+(a[i][k]+b[k][j]);
printf("%d\t",c);
}
c=0;
printf("\n");
}
}
getch();
}

i think the addition is easy now and i try to add all of the programs i can over
here...,

thank you
vinaychalluru

Potrebbero piacerti anche