Hi I think im doing fairly good on this program but for some reason its giving me an error on line 27 this program is supposed to compute two statistical values for an array of 500 integers ranging in value from 0 to 2000 what am i doing wrong?
//Driver.cpp
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include "Functions.h"
using namespace std;
int main()
{
cout<<"\n Functions, arrays, and statistics"
<<"\n\nThis program will compute two statistical values for an"
<<"\narray of 500 integers ranging in value from 0 to 2000.";
int numbers[499], total = 499;
double average;
void FillArray(int numbers[499], int total);
double AveArray(int numbers[499], int total);
average = AveArray(numbers[499], total); //error here
//1 IntelliSense: argument of type "int" is incompatible with parameter of type "int *"
return 0;
}
//Functions.cpp
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include "Functions.h"
using namespace std;
void FillArray(int numbers[], int total)
{
srand(123);
for(int i = 0; i<total; ++i)
{
numbers[i] = rand() % 2001;
}
}
double AveArray(int numbers[], int total)
{
int sum = 0;
double average = 0.0;
for (int i = 0; i < 499; ++i)
sum+=numbers[i];
average = sum/500;
return average;
}
double StdDeviation(int numbers[], int total, double average)
{
int sum = 0;
double finalresult;
for (int i = 0; i < total; i++)
{
sum+=pow((numbers[i]-average),2);
}
finalresult=sum/499;
return finalresult;
}
//functions.h
using namespace std;
void FillArray(int numbers[499], int total);
double AveArray(int numbers[499], int total);
double StdDeviation(int numbers[499], int total, double average);