C Program to Sum Of Two Matrix..

Program By :-> Jayant Purohit
/*This Program is using three arrays(each one is two dimensional array).one for 
storing values of first matrix,one for storing the values of second matrix and the 
third one stores the resultant sum of these two matrixes.
In this program the values are not supplied by the user one may change the code 
according to this requirement. */

#include<conio.h>
#include<stdio.h>
void main()
{
//Two Dimension Array to get hold first Matrix.
int a[3][3]={12,12,12,2,2,2,15,15,15};
//Two Dimension Array to get hold second Matrix.
int b[3][3]={1,1,1,12,12,12,5,5,5};
//Two Dimension Arry to get hold summation Matrix.
int c[3][3];
int i,j;
clrscr();
printf("\nThe Matrix A IS:->");
for(i=0;i<3;i++)
printf("\n%d     %d     %d",a[i][0],a[i][1],a[i][2]);

printf("\nThe Matrix B IS:->");
for(i=0;i<3;i++)
printf("\n%d     %d     %d",b[i][0],b[i][1],b[i][2]);

for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf("\nThe Resultent Matrix is as follow:->");
for(i=0;i<3;i++)
printf("\n%d     %d     %d",c[i][0],c[i][1],c[i][2]);
getch();
}

No comments:

Post a Comment

Please write your Views about this Post here:->;

Pageviews last month

11