Ok I got that figured out now,

new problem that I actually don't understand.

I have now two functions: avgi and avgf which as input have a pointer and a size of the array.

They return the avarages of the arrays one for integers and one for floats.

The error I get is: Undefined reference to `avgi(int*,int)' on line 72.

I dont get this since I use both functions the same way, the only difference is that one accepts an array of integers and the other an array of floats.

Code:

Code:

/*
Header: iostream
Reason: Input/Output stream
Header: stdlib
Reason: For functions rand and srand
Header: time.h
Reason: For function time, and for data type time_t
*/
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <cmath>
using namespace std;
float avgf(float *arrayf,int sizearrayf);
float avgi(int *arrayi,int sizearrayi);
void avarages(int MinimumRange,int MaximumRange,int NumberOfHits,int TimesShoot,float *AvgPointer);
void randomRange(int min, int max,int number, int *pointer);
int main()
{
float Tavg=0.0;
float stdcount=0.0;
float StandardDeviation=0.0;
int NumberOfHits,MinimumRange,MaximumRange,TimesShoot;
//Make the seed for the random function
time_t seed;
time(&seed);
srand((unsigned int) seed);
cout<<"What is your minimum damage\n";
cin>>MinimumRange;
cout<<"What is your maximum damage\n";
cin>>MaximumRange;
cout<<"How many hits does your attack make?\n";
cin>>NumberOfHits;
cout<<"Damge range:"<<MinimumRange<<"-"<<MaximumRange<<"\nHits:"<<NumberOfHits<<endl;
cout<<"How often do you want to shoot?"<<endl;
cin>>TimesShoot;
float avgarray[TimesShoot];
avarages(MinimumRange,MaximumRange,NumberOfHits,TimesShoot,avgarray);
Tavg=avgf(avgarray,TimesShoot);
for(int x=0;x<TimesShoot;x++)
{
stdcount=stdcount+((avgarray[x]-Tavg)*(avgarray[x]-Tavg));
}
StandardDeviation=sqrt(stdcount/TimesShoot);
cout<<"Avarage over time="<<Tavg<<endl;
cout<<"Standard deviation="<<StandardDeviation<<endl;
}
void avarages(int MinimumRange,int MaximumRange,int NumberOfHits,int TimesShoot,float *AvgPointer)
{
for(int i=0;i<TimesShoot;i++)
{
int counter=0;
float avg=0;
float avg2=0;
int array[NumberOfHits];
randomRange(MinimumRange,MaximumRange,NumberOfHits,array);
for(int x=0;x<NumberOfHits;x++)
{
counter=counter+array[x];
}
avg=(float)counter/NumberOfHits;
avg2=avgi(array,NumberOfHits);
cout<<"Avarage for shot nr."<<i+1<<" is: "<<avg<<endl;
cout<<"new function: "<<avg2<<endl;
AvgPointer[i]=avg;
}
return;
}
void randomRange(int min, int max, int number, int *HitsPointer)
{
//get a random number from range min-max
int rnumber;
for(int i=0;i < number;i++)
{
rnumber=rand() % (max-min) + min;
HitsPointer[i]=rnumber;
}
return;
}
float avgf(float *arrayf,int sizearrayf)
{
float counter=0.0;
float avg=0.0;
for(int i=0;i<sizearrayf;i++)
{
counter=counter+arrayf[i];
}
avg=counter/sizearrayf;
return avg;
}
float avgi(float *arrayi,int sizearrayi)
{
float counter=0.0;
float avg=0.0;
for(int i=0;i<sizearrayi;i++)
{
counter=counter+arrayi[i];
}
avg=counter/sizearrayi;
return avg;
}