Saturday 24 December 2011

A Program for ADDITION of two matrix


//*****A program for ADDITION of two matrixes*****//


#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a[10][10],b[10][10],c[10][10],m,n;
clrscr();
printf("\t\t *** ADDITION OF MATRIXES ***");
printf("\nEnter the no. of row & coloumn :\n");
scanf("%d%d",&m,&n);
printf("Enter the elements of 1st matrix:\n");
for(i=0;i<m;i++)
{
 for(j=0;j<n;j++)
 scanf("%d",&a[i][j]);
}
printf("Enter the element of 2nd matrix :\n");
for(i=0;i<m;i++)
{
 for(j=0;j<n;j++)
 scanf("%d",&b[i][j]);
}
for(i=0;i<m;i++)
{
 for(j=0;j<n;j++)
 c[i][j]=a[i][j]+b[i][j];
}
printf("Addition of both matirxes is :\n");
for(i=0;i<m;i++)
{
 for(j=0;j<n;j++)
 printf("%d\t",c[i][j]);
 {
   printf("\n");
 }
}
printf("\nThanks! for using the programe.......@Devesh");
getch();


}


//output look like this....



No comments:

Post a Comment