Showing posts with label matrices addition in cplusplus. Show all posts
Showing posts with label matrices addition in cplusplus. Show all posts

Friday, 30 January 2015

Addition of Two dimensional Array in C++

Structure of the Problem Requirements 

The Program is related to Arrays where we learn how to add two,2 dimensional array in C++ program. The two dimensional array is one which vary from both sides. The one side indicate the rows and the second side is columns . 

Source Code

#include<iostream>
using namespace std;
int main ()
{
cout<<"\t \t \t LEP Tutorials \n \n \n ";
int nums1 [3][3],nums2[3][3],a,b;
cout<<"\t Matrix 1 \n \n";
for(a=0;a<3;a++)
{
for(b=0;b<3;b++)
{
cout<<"Enter number :";
cin>>nums1[a][b];
}
}
cout<<"\t Matrix 2 \n";
for(a=0;a<3;a++)
{
for(b=0;b<3;b++)
{
cout<<"Enter number :";
cin>>nums2[a][b];
}
}
cout<<"\t Sum \n";
for(a=0;a<3;a++)
{
for(b=0;b<3;b++)
{
cout<<nums1[a][b]+nums2[a][b]<<" ";
}
cout<<endl;
}
}

Output of the Progrm

Addition of Two dimensional Array in C++