I can't detect the problem to this program that i've made.
there's a problem for sum and average.
#include <iostream>
using namespace std;
float sum(float[], int); // Declaration of function
float average(int, float);// Declaration of function
int main()
{
int numMonth;
int count;
float *sales;
float userInfo;
cout << "Please input the number of monthly sales to be input: "<<endl; //Get the array size.
cin >> numMonth;
sales = new float[numMonth]; // Allocate the array.
for (count = 1; count <= numMonth; count++) //Fill the array with values.
{
cout << "Please input the sales for month " << count << endl;
cin >> userInfo;
userInfo = sales[count];
}
float sum(float sales[], int numMonth);//Calling function
cout << "The total sales for the year is $" << sum << endl;
float average (int numMonth, float sum);// Calling function
cout << "The average monthly sale is $" << average << endl;
delete sales;
system("pause");
return 0;
}
float sum(float sales[], int numMonth)
{
float sum;
float holder=0;
int count;
for (count = 0; count <= numMonth; count++)
holder = holder + sales[count];
sum = holder;
return sum;
}
float average(int numMonth, float sum)
{
float average;
average = sum / numMonth;
return average;
}