Make a C++ program that will display the sum of the values of ingeter array with a length of 6. The values of array will be input values from the user. Use for Loops.
#include <iostream>
using namespace std;
int main()
{
const int N=6;
double sum = 0;
int arr[N];
cout << "Please, fill an array with a length of "<<N<<": ";
for (int i = 0; i < N; i++)
{
cin >> arr[i];
}
for (int i = 0; i < N; i++)
{
sum+=arr[i];
}
cout << "The sum of the values is "<<sum;
}
Comments
Leave a comment