// Program to add of two matrices
#include
#include
void main()
{
clrscr();
int A[10][10], B[10][10], C[10][10];
int n,i,j,row,col;
printf("Enter the order of matrix\n");
scanf("%d %d",&row ,&col);
printf("Enter the element of matrix A\n");
for(i=0;i|
{
for(j=0;j
{
scanf("%d", &A[i][j]);
}
}
printf("Enter the element of matrix B\n");
for(i=0;i|
{
for(j=0;j
{
scanf("%d", &B[i][j]);
}
}
for(i=0;i|
{
For(j=0;j
{
C[i][j] = A[i][j]+B[i][j];
}
}
printf("Sum of matrix is...\n");
for(i=0;i|
{
for(j=0;j
{
printf("%d",C[i][j]);
}
printf("\n");
}
getch();
}
Algorithm
· Declare A[10][10], B[10][10], C[10][10] as integer
· Declare n, i, j, row, col as integer
· Write ("order of matrix")
· Read("row and col”)
· Write("element of matrix A")
· for(i=0;i|
· for(j=0;j
· Read("A[i][j]”)
· Write("element of matrix B")
· for(i=0;i|
· for(j=0;j
· Read("B[i][j]”)
· for(i=0;i|
· For(j=0;j
· C[i][j] = A[i][j]+B[i][j]
· Read("Sum of matrix is...")
· for(i=0;i|
· for(j=0;j
· Read("C[i][j]”)
· Read("In next line")
· stop
0 comments:
Post a Comment