Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a C++ program to sum the content of two arrays: arrayA and arrayB and stor

ID: 3686059 • Letter: W

Question

write a C++ program to sum the content of two arrays: arrayA and arrayB and store the sum in a third array arrayC.

Use the following 3 functions:

1- Finction void read (int arrayA[10],int arrayB[10]); that askes the user to enter 10 values for each array. Use any loop.

2- Function void sum(int arrayA[10],int arrayB[10],int arrayC[10]);that sums the value stored in the first cell of arrayA with the value stored in the first cell of arrayBand stores it in the first cell of arrayC.

3- function void print(int anArray[10]);that prints the content of an array .

in the main program:

1- declare all arrays to be of type int and each can hold 10 integers.

2- call function read.

3- call function sum.

4- print the content of arrayA, arrayB, arrayC by calling function print for each array.

Explanation / Answer

// Example program
#include <iostream>
#include <string>
using namespace std;

void read (int A[10],int B[10])
{
int i,j;
cout<<"Please enter ten numbers for Array A"<<endl;
for(i=0;i<10;i++)cin>>A[i];

cout<<"Please enter ten numbers for Array B"<<endl;
for(i=0;i<10;i++)cin>>B[i];

return;
}
void sum(int A[10],int B[10],int C[10])
{
for(int i=0;i<10;i++)C[i]=A[i]+B[i];
return;
}

void print(int A[10])
{
for(int i=0;i<10;i++)cout<<A[i]<<' ';
cout<<' ';
return;
}
int main()
{
int A[10],B[10],C[10];
read(A,B);
sum(A,B,C);
print(A);
print(B);
print(C);
}