0% found this document useful (0 votes)
4 views1 page

C++ Array Addition Example

This C++ program allows a user to enter the number of elements for two arrays, input values for those arrays, then outputs the sum of the corresponding elements of each array. The program defines two arrays to hold user input, prompts the user to enter the array size and values for both arrays, then uses a for loop to iterate through the arrays and output the sum of each pair of elements.

Uploaded by

abhi kr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

C++ Array Addition Example

This C++ program allows a user to enter the number of elements for two arrays, input values for those arrays, then outputs the sum of the corresponding elements of each array. The program defines two arrays to hold user input, prompts the user to enter the array size and values for both arrays, then uses a for loop to iterate through the arrays and output the sum of each pair of elements.

Uploaded by

abhi kr
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Array Addition

#include<iostream>
using namespace std;
main()
{
int first[20], second[20], c, n;
cout << "Enter the number of elements in the array ";
cin >> n;
cout << "Enter elements of first array " << endl;
for ( c = 0 ; c < n ; c++ )
cin >> first[c];
cout << "Enter elements of second array " << endl;
for ( c = 0 ; c < n ; c++ )
cin >> second[c];
cout << "Sum of elements of two arrays " << endl;
for ( c = 0 ; c < n ; c++ )
cout << first[c] + second[c] << endl;
return 0;
}

You might also like