Wednesday, 1 October 2014

WAP to perform Multiplication between two matrix.

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a[10][10],b[10][10],c[10][10];
int i,j,x,y,m,n,k;
printf("\t\n Enter the no. of row and column in Matrix A :");
scanf("%d%d",&x,&y);
printf("\n\t Enter the no. of row and column in Matrix B :");
scanf("%d%d",&m,&n);
printf("\n\t Enter the Matrix of A : ");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\n\tEnter the Matrix of B : ");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<x;i++){
for(j=0;j<n;j++) {
for(k=0;k<y;k++){
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf("\n\t Multiplication is :  ");
for(i=0;i<x;i++)
{
for(j=0;j<n;j++)
{
printf("%d  ",c[i][j]);
}
printf("\n\t\t\t");
}
getch();
}

No comments:

Post a Comment

Please write your doubts