Program for Matrix Addition


#include<iostream.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j;
clrscr();
cout<<"Enter the Elements of the Ist Matrix";
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>a[i][j];
cout<<"Enter the Elements of the IInd Matrix";
for(i=0;i<3;i++)
for(j=0;j<3;j++)
cin>>b[i][j];
//Sum starts here
for(i=0;i<3;i++)
for(j=0;j<3;j++)
c[i][j]=a[i][j]+b[i][j];
cout<<"\nThe addition of input  Matrix is\n";
for(i=0;i<3;i++)
{
cout<<"\n";
for(j=0;j<3;j++)
cout<<"\t"<<c[i][j];
}
cout<<"\nPress any key to continue...";
getch();
}
Output
Enter the Elements of the Ist Matrix
1              2              3
4              5              6
7              8              9
Enter the Elements of the IInd Matrix
9              8              7
6              5              4
3              2              1
The addition of input  Matrix is
        10      10      10
        10      10      10
        10      10      10
Press any key to continue...

Comments

  1. Dear reader Thanks for commenting
    I will help you so please tell me what kind of program you need to be done.

    ReplyDelete

Post a Comment

Popular posts from this blog

Program for calculating Simple Interest using the concept of Default Arguments

Program: Maximum number in three numbers in visual basic

Program for Checking whether the given number is Palindrome or not