So I'm pretty new to C++ programming and am trying to use what I've learned so far to create a program that takes a user's input and averages it. I'm confident most of my code is correct, but whenever I try to compile it I get an error saying it can't convert 'float' to 'float*' for argument '1' to 'float averageMachine(float*, size). Here's what my code looks like.
#include <iostream>
#include <string>
using namespace std;
float averageMachine(float array[], int arraySize)
{
float sum;
for(unsigned int i = 0; i<arraySize; ++i)
{
sum+= array[i];
}
float average=sum/arraySize;
return average;
}
int main(void)
{
int size= 1;
cout<<"How many numbers are you averaging?"<<endl;
cin >> size;
float* numbers=new float[size];
cout<<"Please insert "<<size<<" whole positive integers."<<endl;
for(int i = 0; i < size; i++)
{
float number;
cin >> number;
numbers[i] = number;
}
float finalAverage = averageMachine(*numbers, size);
cout << "The average of those numbers is " << finalAverage << "."<<endl;
return 0;
}