Home Answers Viewqa Development-process C Program for Addtion of 2*2 Diagnol Matrix

 
 


sushant
C Program for Addtion of 2*2 Diagnol Matrix
1 Answer(s)      3 years and 5 months ago
Posted in : Development process

View Answers

December 17, 2009 at 12:04 PM


Hi Friend,

Try the following code:

#include <stdio.h>

void main()
{
int a[2][2],b[2][2],c[2][2],i,j;
clrscr();
printf("Enter the First matrix:\n");
for(i=0;i<2;i++) {
for(j=0;j<2;j++){
scanf("%d",&a[i][j]);
}
}
printf("\nThe First matrix is:\n");
for(i=0;i<2;i++)
{
printf("\n");
for(j=0;j<2;j++)
printf("%d\t",a[i][j]);
}
printf("\nEnter the Second matrix:\n");
for(i=0;i<2;i++){
for(j=0;j<2;j++){

scanf("%d",&b[i][j]);
}
}
printf("\nThe Second matrix is:\n");
for(i=0;i<2;i++)
{
printf("\n");
for(j=0;j<2;j++)
printf("%d\t",b[i][j]);
}
for(i=0;i<2;i++)
for(j=0;j<2;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nThe Addition of two matrix is:\n");
for(i=0;i<2;i++)
{
printf("\n");
for(j=0;j<2;j++)
printf("%d\t",c[i][j]);
}
getch();
}

Thanks









Related Pages:
C#
c++
c++
c++

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.