br/>

Sunday, November 23, 2014

C/C++ code for Two adding matrix

Hey guys below is the code for adding two matrix of 3 x 3 

#include<iostream.h>            (add this file if using on C++)
#include<stdio.h>
#include<conio.h>
void main()

{


int n,a[3][3],b[3][3],c[3][3];
printf(“Enter the Matrix A \n”);   \\Enter the matrix A
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{
scanf(“%d”,%a[i][j]);
}
}
printf(“Enter the Matrix B \n”);  \\Enter the matrix B
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{
scanf(“%d”,&b[i][j]);
c[i][j]=a[i][j]+b[i][j];   \\Addition of elements of A & B
}
}
printf(“Summation matrix c is :\n”);
for(i=0;i<n;i++)
{for(j=0;j<n;j++)
{
printf(“%d \t”,c[i][j]);
}
printf(“\n”);
}
getch();
}

No comments:

Post a Comment

Please vote for the post......and leave a reply...no need t sign in for voting and commenting

Popular Posts