## Write a program to add two matrices.

/*
PROGRAM:
——–
Write a program to add two matrices.
*/
#include<stdio.h>
#include<conio.h>

void main()
{
int a[3][3],b[3][3],c[3][3]={0},i,j;
clrscr();

printf(“Enter values for Matrix A: “);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“\nRow %d and Column %d: “,i+1,j+1);
scanf(“%d”,&a[i][j]);
}
}
printf(“\n\nEnter values for Matrix B: “);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“\nRow %d and Column %d: “,i+1,j+1);
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf(“\n\n\nAddition of Array A and B\n\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“%4d”,c[i][j]);
}
printf(“\n”);
}
getch();
}
/*
OUTPUT:
——-
Enter values for Matrix A:
Row 1 and Column 1: 4

Row 1 and Column 2: 5

Row 1 and Column 3: 6

Row 2 and Column 1: 2

Row 2 and Column 2: 3

Row 2 and Column 3: 4

Row 3 and Column 1: 5

Row 3 and Column 2: 2

Row 3 and Column 3: 4
Enter values for Matrix B:
Row 1 and Column 1: 1

Row 1 and Column 2: 2

Row 1 and Column 3: 3

Row 2 and Column 1: 5

Row 2 and Column 2: 6

Row 2 and Column 3: 7

Row 3 and Column 1: 8

Row 3 and Column 2: 6

Row 3 and Column 3: 4

Addition of Array A and B

5 7 9
7 9 11
13 8 8
*/