/* ------------------------------------------------------------*
| Program Addition of Two matrix |
| Author : Mr.K.Manikanta created @ 29-10-2011 |
| in V.R.S and Y.R.N college of Eng & Tech |
*------------------------------------------------------------*/
#include<stdio.h> /*Linkage Section*/
#include<conio.h> /*Linkage Section*/
int main()
{
int a[10][10],b[10][10],c[10][10],i,j,p,q,m,n; /*Initilization of Varibles*/
clrscr();
printf("Enter First Matrix row and column size");
scanf("%d %d",&m,&n);
printf("Enter Values into first Matrix \n");
for(i=0;i<m;i++) /*First Matrix */
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("Enter Second row and column size");
scanf("%d %d",&p,&q);
printf("Enter Values into Second Matrix"); /*Second Matrix*/
for(i=0;i<p;i++)
for(j=0;j<q;j++)
scanf("%d",&b[i][j]);
if(m==p && n==q)
{
printf("The result of Addition Matrix is: \n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf(" %4d",c[i][j]); /*Result of addition matrix*/
printf("\n");
}
}
else
{
printf("Your given matrix values addition is not possible");
}
getch();
| Program Addition of Two matrix |
| Author : Mr.K.Manikanta created @ 29-10-2011 |
| in V.R.S and Y.R.N college of Eng & Tech |
*------------------------------------------------------------*/
#include<stdio.h> /*Linkage Section*/
#include<conio.h> /*Linkage Section*/
int main()
{
int a[10][10],b[10][10],c[10][10],i,j,p,q,m,n; /*Initilization of Varibles*/
clrscr();
printf("Enter First Matrix row and column size");
scanf("%d %d",&m,&n);
printf("Enter Values into first Matrix \n");
for(i=0;i<m;i++) /*First Matrix */
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("Enter Second row and column size");
scanf("%d %d",&p,&q);
printf("Enter Values into Second Matrix"); /*Second Matrix*/
for(i=0;i<p;i++)
for(j=0;j<q;j++)
scanf("%d",&b[i][j]);
if(m==p && n==q)
{
printf("The result of Addition Matrix is: \n");
for(i=0;i<m;i++)
for(j=0;j<n;j++)
c[i][j]=a[i][j]+b[i][j];
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf(" %4d",c[i][j]); /*Result of addition matrix*/
printf("\n");
}
}
else
{
printf("Your given matrix values addition is not possible");
}
getch();
}
Output
Enter First Matrix row and column size
2
2
Enter Values into first Matrix
2
4
3
6
Enter Second row and column size
2
Enter Values into first Matrix
2
4
3
6
Enter Second row and column size
2
2
Enter Values into Second Matrix
2
Enter Values into Second Matrix
5
4
2
3
The result of Addition Matrix is:
7 8
5 9
4
2
3
The result of Addition Matrix is:
7 8
5 9
0 comments:
Post a Comment