Ok. First off, here is the question I am answering
Problem 3: Write a program that will read monthly sales into a dynamically allocated array. The program will input the size of the array from the user. It will call a function that will find the yearly sum (the sum of all the sales). It will also call another function that will find the average.
The problem I am having is that the program will run, and go through the first loop, but when it comes to the point of calling the functions, it just skips over them. I have run it in Dev C++ and Visual 2008, and can't get it to work. Here is the code.
#include <iostream>
using namespace std;
float sum(float[], int);
float average(int, float);
int main()
{
int size;
int count;
float *sales;
float userInfo;
cout << "Please enter the size you want the array to be\n";
cin >> size;
sales = new float[size];
for (count = 0; count < size; count++)
{
cout << "Please enter the information for array position" << count << endl;
cin >> userInfo;
sales[count] = userInfo;
}
float sum(int sales[], int size);
cout << "The sum of the Figures you entered is " << sum << endl;
float average (int size, float sum);
cout << "The average of the figures you entered is " << average << endl;
return 0;
}
float sum(float sales[], int size)
{
float sum;
float holder;
int count;
for (count = 0; count < size; count++)
holder += sales[count];
sum = holder;
return sum;
}
float average(int size, int sum)
{
int average;
average = sum / size;
return average
}