/*
Name: WAP to calculate the addition of two matrics
Author: Parveen Malik
Date: 18/09/11 03:31
*/
#include<stdio.h>
#include<conio.h>
int main(void)
{
float a[10][10],b[10][10],c[10][10];
int i,j,m,n;
printf("Enter the size of Matrices as m,n : ");
scanf("%d%d",&m,&n);
printf("Enter %d elements of Matrix A row-wise\n",m*n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%f",&a[i][j]);
}
}
printf("Enter the %d elements of Matrix B row-wise\n",m*n);
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%f",&b[i][j]);
}
}
/* now add A Matrix + B Matrix */
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
/* to print the result */
printf("\n Addition of Matrix A + Matrix B : \n\n");
for (i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%3.2f\t",c[i][j]);
}
printf("\n");
}
getch();
return 0;
}
OUTPUT :
0 comments:
Post a Comment