0

This code finds the sum & average of the range of numbers that were chosen. I have

int begin = 0, end = 0,sum = 0.0, avg = 0;

because I get an error saying that all of those need to be initialized, yet by doing so it gives me the results to be zero's instead of the answer. How do I fix this?

Also, I have a feeling that my math is incorrect & if so, I would appreciate some guidance.

Thank you.

```
#include <iostream>
using namespace std;
void GetData(int begin, int end);
void Calc(int begin, int end, int sum, int avg);
void Display(int begin, int end, int sum, int avg);
int main()
{
int begin = 0,
end = 0,
sum = 0.0,
avg = 0;
GetData(begin, end);
Calc(begin, end, sum, avg);
Display(begin, end, sum, avg);
return 0;
}
void GetData(int begin, int end)
{
cout << "number to start at: ";
cin >> begin;
cout << "Number to end at: ";
cin >> end;
}
void Calc(int begin, int end, int sum, int avg)
{
while(begin < end)
{
int nn = begin;
nn++;
sum += nn;
avg = sum/nn;
}
}
void Display(int begin, int end, int sum, int avg)
{
cout << "the sum between " << begin << " & " << end << " is " ;
<< sum << " & " << endl << " average"<< avg;
}
```