/*Multiplication of Matrices*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a[10][10], b[10][10], c[10][10];
int i,j,n,m,k;
clrscr();
printf("\n\t Multiplication of two matrices");
printf("\nEnter the no. of row and columns:");
scanf("%d%d",&m,&n);
printf("\nEnter the first matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nEnter the Second matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\nMultiplication of two matrices:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
{
c[i][j]= c[i][j] + a[i][k] * b[k][j];
}
printf("%d",c[i][j]);
printf("\t");
}
printf("\n");
}
getch();
}
OUTPUT
Multiplication of two matrices
Enter the no. of row and columns:2 2
Enter the first matrix:
2 3
4 5
Enter the second matrix:
2 3
4 5
Multiplication of two matrices:
16 21
28 37
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a[10][10], b[10][10], c[10][10];
int i,j,n,m,k;
clrscr();
printf("\n\t Multiplication of two matrices");
printf("\nEnter the no. of row and columns:");
scanf("%d%d",&m,&n);
printf("\nEnter the first matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("\nEnter the Second matrix:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("\nMultiplication of two matrices:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
{
c[i][j]= c[i][j] + a[i][k] * b[k][j];
}
printf("%d",c[i][j]);
printf("\t");
}
printf("\n");
}
getch();
}
OUTPUT
Multiplication of two matrices
Enter the no. of row and columns:2 2
Enter the first matrix:
2 3
4 5
Enter the second matrix:
2 3
4 5
Multiplication of two matrices:
16 21
28 37
Comments
Post a Comment