source file name: Matadd.C
#include <stdio.h>
int main()
{
int i,j;
int A[3][3]={{1,2,3},{4,5,6},{7,8,9}};
int B[3][3]={{2,2,2},{3,6,9},{10,20,30}};
int C[3][3];
//clrscr();
printf("\n given Matrix A \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",A[i][j]);
}
printf("\n");
}
printf("\n given Matrix B: \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",B[i][j]);
}
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
C[i][j]= A[i][j]+B[i][j];
}
}
printf("\n addition Matrix C \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d ",C[i][j]);
}
printf("\n");
}
//getch();
return 0;
}
output:
0 Comments
Post a Comment