arrays addition

can anybody just sort it out,, that whats the source code to write the answer of arrays after addition.. in the below code i used 2 arrays as arguments by using functions,, and then add those arrays and it gives the answer correect,, but i want the answer in this format .. 5+5+5+5=20
6+6+6+6=24
OR the answer of your first array is =20
the answer of your second array is =24
Answer plzzzzzz???? helppppppp??????

#include <iostream>

using namespace std;
int addarray(int arg[], int length){
int r=0;
for (int i=0; i<length; i++)
r= r+arg[i];
cout<< r <<" ";
cout<<"\n";
return r;

}

int main()
{
int firstarray[]={5,5,5,5};
int secondarray[]={6,6,6,6};
addarray(firstarray,4);
addarray(secondarray,4);
return 0;
}


int addarray(int arg[], int length){
int r=0;
for (int i=0; i<length; i++)
r= r+arg[i];
return r;

}

int main()
{
int firstarray[]={5,5,5,5};
int secondarray[]={6,6,6,6};
cout << "the answer of your first array is =" << addarray(firstarray,4) << endl;
cout << "the answer of your second array is =" << addarray(secondarray,4) << endl;
return 0;
}

Topic archived. No new replies allowed.