For beginners
{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.}
{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[10][10],m2[10][10],r1,r2,c1,c2,sum[10][10],i,j;
printf("enter the order of matrix");
printf("\n row \n");
scanf("%d",&r1);
printf("\n coloumn \n");
scanf("%d",&c1);
printf("\n enter the order of second matrix \n");
printf("\n row \n");
scanf("%d",&r2);
printf("\n coloumn \n");
scanf("%d",&c2);
if(r1==r2&&c1==c2)
{
printf("\n enter the first matrix \n");
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
scanf("%d",&m1[i][j]);
}
}
printf("entered matrix is");
for(i=0;i<r1;i++)
{
printf("\n\n");
for(j=0;j<c1;j++)
{
printf("%5d",m1[i][j]);
}
}
printf("\n enter the second matrix \n");
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
scanf("%d",&m2[i][j]);
}
}
printf("entered matrix is");
for(i=0;i<r1;i++)
{
printf("\n\n");
for(j=0;j<c1;j++)
{
printf("%5d",m2[i][j]);
}
}
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
sum[i][j]=m1[i][j]+m2[i][j];
}
}
printf("\n the result is\n");
for(i=0;i<r1;i++)
{printf("\n\n");
for(j=0;j<c1;j++)
{
printf("%5d",sum[i][j]);
}
}
}
else
{
printf("\n addition is not possible");
}
getch();
}
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