C++ Program to find sum of two arrays
Program
#include <iostream>
using namespace std;
int main()
{
int a[10], b[10], c[10], n, i;
cout << "Enter the number of elements:\t";
cin >> n;
cout << "Enter " << n << " elements for array 1:" << endl;
for (i = 0; i < n; i++)
cin >> a[i];
cout << "Enter " << n << " elements for array 2:" << endl;
for (i = 0; i < n; i++)
cin >> b[i];
for (i = 0; i < n; i++)
c[i] = a[i] + b[i];
cout << "Sum of two array elements are:" << endl;
for (i = 0; i < n; i++)
cout << c[i] << endl;
return 0;
}
Output
Enter the number of elements: 6
Enter 6 elements for array 1:
13
32
87
15
58
37
Enter 6 elements for array 2:
95
72
01
84
48
93
Sum of two array elements are:
108
104
88
99
106
130