#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
int a[10][10],b[10][10],c[10][10],i,j;
printf("enter the no. of rows,columns.");
scanf("%d%d",&x,&y);
clrscr();
printf("enter the elements of first matrix.");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("enter the elements of second matrix..");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
for(i=0;i<x;i++)
{
printf("\n");
for(j=0;j<y;j++)
{
printf("%d\t",c[i][j]);
}
}
getch();
#include<conio.h>
void main()
{
int x,y;
int a[10][10],b[10][10],c[10][10],i,j;
printf("enter the no. of rows,columns.");
scanf("%d%d",&x,&y);
clrscr();
printf("enter the elements of first matrix.");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("enter the elements of second matrix..");
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<x;i++)
{
for(j=0;j<y;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
for(i=0;i<x;i++)
{
printf("\n");
for(j=0;j<y;j++)
{
printf("%d\t",c[i][j]);
}
}
getch();
}
No comments:
Post a Comment