adds

Sum of matrices using c++ Programme:


THEORY:
Two matrices can be added if they are of the same order.

CODING:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
int a[3][3],b[3][3],c[3][3];
int i,j;
clrscr();
cout<<"Enter the elements of 1st matrix:\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cin>>a[i][j];
}
}
cout<<"Enter the elements of 2nd matrix:\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cin>>b[i][j];
}
}
cout<<"The 1st matrix is :\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<endl;
}
cout<<"The 2nd matrix is :\n";
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<b[i][j]<<"\t";
}
cout<<endl;
}
cout<<"Addition of two matrices is:\n";
for (i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
c[i][j]=a[i][j]+b[i[j];
cout<<c[j][i]<<"\t";
}
cout<<endl;
}
getch();
}
OUTPUT:

Model syllabus (+3)Downoad


List of all practicals:   Download

Get all Books:  Download

C++ Program : Click                                       Scilab Program : Click

Syllabus For:                                                   Get all B.Sc Physics Notes
                                                                                         CLICK

IIT-JAM    
                                                           


  • How to Prepare for IIT-JAM  ⇠ ⇠ Click Here

Post a Comment

Previous Post Next Post