Answer to Question #331417 in C++ for Chubby

Question #331417

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.


1
Expert's answer
2022-04-20T12:40:24-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS