CODING:
#include<stdio.h>
#include<conio.h>
void main( )
{
int a[10][10],b[10][10],c[10][10],m,n,i,j;
clrscr( );
printf("Enter order of matrices ");
scanf("%d%d",&m,&n);
printf("Enter values of first matrix\n);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
printf("Enter values of a[%d][%d] ",i,j);
scanf("%d",&a[i][j]);
}
}
printf(\nEnter values of second matrix\n);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
printf("Enter values of b[%d][%d] ",i,j);
scanf("%d",&b[i][j]);
}
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\nSum of a[%d][%d] and b[%d][%d] = %d",i,j,i,j,c[i][j]);
}
}
getch( );
}
----------------------------------------------------------------------------------------------------------------------------
OUTPUT:
For any query or suggestion please comment below....
#include<stdio.h>
#include<conio.h>
void main( )
{
int a[10][10],b[10][10],c[10][10],m,n,i,j;
clrscr( );
printf("Enter order of matrices ");
scanf("%d%d",&m,&n);
printf("Enter values of first matrix\n);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
printf("Enter values of a[%d][%d] ",i,j);
scanf("%d",&a[i][j]);
}
}
printf(\nEnter values of second matrix\n);
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
printf("Enter values of b[%d][%d] ",i,j);
scanf("%d",&b[i][j]);
}
}
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\nSum of a[%d][%d] and b[%d][%d] = %d",i,j,i,j,c[i][j]);
}
}
getch( );
}
----------------------------------------------------------------------------------------------------------------------------
OUTPUT:
OUTPUT WINDOW |
For any query or suggestion please comment below....
Thanks a lot.. nice C program for beginner programmers like me add two matrix.
ReplyDelete