Hi,
Okay, I really need help with this program please...
I have to create a program which;
Contains a function called sumN() which takes an int n as an argument and returns an int which is the sum of all integers between 1 and n.
In the main() it asks the user;
How many values (s)he wants to enter (maximum 50);
Asks for the values and stores them into an array int a[].
Prints to the console sumN(a) for all the elements of a[] that have been entered by the user.
I've started it, but I don't know how to do the rest because I'm sooo confused.
Here's what I have so far;
#include <iostream>
using namespace std;
int main()
{
double temp, set[50];
int size, t, i, value ;
cout << "How many values do you wish to enter?\n";
cin >> size;
while (size>50)
{
cout << "Sorry, that was above 50" << endl;
cout << "How many values do you wish to enter?\n";
cin >> size;
}
cout << "Enter the values:\n";
for (value=0; value<size; value++)
cin >> set[value];
cout << "Here are your values:\n";
for (t=0; t<size; t++)
cout << set[t] << "\n";
return 0;
}
I'd be very grateful if someone could help me as soon as possible!
Thanks :)