### How to sum two arrays into a third array

Hi, im new at c++ and I would like to make two arrays that have 8 values each and each value is generated by ran(). After this I would like to sum each value in their current positions and pass them to a third array. How could I do this?
If'n the 3rd array have the same number of elements as the other two arrays, 8 elements, use a loop.

Easiest type of loop for this exercise is a for loop.

https://www.learncpp.com/cpp-tutorial/for-statements/
Ok, I have made the program but now my problem is that I dont understand how to use the ran() to make each value of the array be random. Any advice for that? I made the program for the user to input the numbers but I need it to be generated random. Here is what I made.

using namespace std;
int main()
{
int firstarray[5];
int secondarray[5];
int sumarrays[5];
int count;

cout<<"Please enter the values in 1st array: ";
for(count=0; count<5;count++)
{
cin>>firstarray[count];
}

cout<<"Please enter the values in 2st array: ";
for(count=0; count<5;count++)
{
cin>>secondarray[count];
}

cout<<"1st arrays value: \n\n";
for(count=0; count<5; count++)
{
cout<<firstarray[count]<<"";
}

cout<<"2nd arrays value: \n\n";
for(count=0; count<5; count++)
{
cout<<secondarray[count]<<"";
}

// sum of arrays
for(count=0; count<5; count++)
{
sumarrays[count] = firstarray[count] + secondarray[count];
}

cout<<"\n\n Sum of two arrays is : \n\n";
for(count=0; count<5; count++)
{
cout<<sumarrays[count]<<"";
}
return 0;
}
Topic archived. No new replies allowed.