OCJP

Sum of Two Matrix

#include<stdio.h>
#include<conio.h>

#define R 3
#define C 3

void main()
{
int mat1[R][C];
int mat2[R][C];
int mat3[R][C];

int i,j;
clrscr();

printf("\nEnter %d Values:",R*C);

for(i=0;i<R;i++)
{
for(j=0;j<C;j++)
{
scanf("%d",&mat1[i][j]);
}
}
printf("\nEnter %d Values:",R*C);

for(i=0;i<R;i++)
{
for(j=0;j<C;j++)
{
scanf("%d",&mat2[i][j]);
mat3[i][j]=mat1[i][j] + mat2[i][j];
}
}


printf("\nMatrix Values :\n");
for(i=0;i<R;i++)
{
for(j=0;j<C;j++)
{
printf("%4d",mat3[i][j]);
}
printf("\n");
}

getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *


× How can I help you?