Write a Program for Addition of 2X2 matrix

/*Program for Addition of 2X2 matrix*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,a[2][2],b[2][2],c[2][2];

printf("\n\nAccepting the Values of Array A: ");

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\n\nEnter any number: ");
scanf("%d",&a[i][j]);
}
}

printf("\n\nAccepting the Values of Array B: ");

for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("\n\nEnter any number: ");
scanf("%d",&b[i][j]);
}
}
printf("\n\nDisplaying the Values of Array c: ");

for(i=0;i<2;i++)
{
printf("\n\n");
for(j=0;j<2;j++)
{
c[i][j]=a[i][j]+b[i][j];

printf(" %d ",c[i][j]);

}
}
getch();
}


Previous
Next Post »