C PROGRAM |
#include <stdio.h>
#include <conio.h>
void main()
{
int a[10][10],b[10][10],c[10][10],i,j,rows,columns;
printf("Enter the number of the rows");
scanf("%d",&rows);
printf("\n Enter the number of the columns");
scanf("%d",&columns);
printf(" Enter the elements of the first matrix \n");
for(i=0;i<rows;i++)
{
for(j=0;j<columns;j++)
{
scanf("%d",&a[i][j]);
}
}
printf(" Enter the elements of the second matrix \n");
for(i=0;i<rows;i++)
{
for(j=0;j<columns;j++)
{
scanf("%d",&b[i][j]);
}
}
printf("sum of two matrix is \n");
for(i=0;i<rows;i++)
{
for(j=0;j<columns;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("%d \n",c[i][j]);
}
}
getch();
}
OUTPUT :
Enter the number of rows2
Enter the number of columns2
Enter the elements of the first matrix
1 1
1 1
Enter the elements of the second matrix
1 1
1 1
sum of two matrix is
2
2
2
2
Process finished.
No comments:
Post a Comment