{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7 like Code::Blocks,dev c++ . Download dev c++ its free and install it in your computer.open dev c++ go to file-->new-->source file.}
#include<stdio.h>
#include<conio.h>
main()
{
int m1[20][20],m2[20][20],mult[20][20],i,j,k,r1,c1,r2,c2;
printf("Enter number of rows and columns of first matrix (less than 20)\n");
scanf("%d%d",&r1,&c1);
printf("Enter number of rows and columns of second matrix (less than 20)\n");
scanf("%d%d",&r2,&c2);
if(r2==c1)
{
printf("Enter the First matrix \n");
printf("enter the numbers in Row wise\n");
for(i=0;i<r1;i++)
for(j=0;j<c1;j++)
scanf("%d",&m1[i][j]);
printf("First Matrix is :\n");
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
printf("%d\t",m1[i][j]);
printf("\n");
}
printf("Enter the Second matrix \n");
printf("enter the numbers in Row wise\n");
for(i=0;i<r2;i++)
for(j=0;j<c2;j++)
scanf("%d",&m2[i][j]);
printf("Second Matrix is:\n");
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
printf("%d\t",m2[i][j]);
printf("\n");
}
printf("product of the Matrices is:\n");
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
mult[i][j]=0;
for(k=0;k<r1;k++)
mult[i][j]+=m1[i][k]*m2[k][j];
printf("%d\t",mult[i][j]);
}
printf("\n");
}
}
else
{
printf("Matrix multiplication cannot be done");
}
getch();
return 0;
}
For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}
No comments:
Post a Comment