0

The program asks to input an integer larger than one. the number is

then passed into a function that calculates the sum of squares from

1 to that integer the output should be the value of the integer and the

sum(labeled).

A negative input value signals the end of the data.

so far I got to the point where I can add all the numbers (sum of squares) of any

number input by the user...

I have to show the numbers being added but I so do not know how to do it :/

so for example if I input this

integer 5

the sum of squares is 55....

what I want to know is how to diplay 1+4+9+16+25 next to the 55 (above).

any idea(s)?.

```
#include<cmath>
#include<iostream>
using namespace std;
int sumsq(int & number,int & sum,int & i);
void errorcheck(int number);
int main()
{
int number;
int sum;
int i;
cout << "Enter number (>= 0): ";
cin >> number;
errorcheck(number);
sumsq(number, sum,i);
system("pause");
return 0;
}
int sumsq(int & number,int & sum,int & i)
{
do
{
for (i =1; i <= number; i++)
sum =(number*(number+1)*((2*number)+1))/6;
cout<<"the sum of squares is"<<sum<<i++<<endl;
i++;
}
while ( i<=number);
return sum;
} // sumsq
void errorcheck(int number)
{
while (number<=1)
{cout<<"wrong input..";
cin.clear();
cin.ignore(1000);
}
}
```

*Edited 6 Years Ago by mmgoicochea*: n/a