My First Array

closed account (N7GEwA7f)
I am having some trouble setting up my function calls in my c++ program if someone could help that would be great. Thanks in advance.

#include <IOMANIP>
#include <IOSTREAM>
#include <FSTREAM>
#include <CMATH>
using namespace std;

const int MAXSIZE = 100;


int loadArray(ifstream& infile, double data[], int arrayLimit);
int findMax(resist, numPts);
int findMin(resist, numPts);
int calcMean(resist, numPts);
int geomMean(resist, numPts);
int rmsAvg(resist, numPts);
int harmMean(resist, numPts);
void sortValues(int resist, int numPts);

int main()
{
double resist[MAXSIZE];//maxsize of the resist
int numPts = 0;//number of points
ifstream infile("HW9resist.txt");
if (!infile)
{
cout<<"Error: could not open file"<<endl;
infile.close();
return 1;
}

numPts = loadArray(infile,resist, MAXSIZE);

cout<<"The maximum value is"<<findMax(resist, numPts)<<endl;

cout<<"The minimum value is"<<findMin(resist, numPts)<<endl;

cout<<"The mean is"<<calcMean(resist, numPts)<<endl;

cout<<"The geometric mean is"<<geomMean(resist, numPts)<<endl;

cout<<"The rms average is"<<rmsAvg(resist, numPts)<<endl;

cout<<"The harmonic mean is"<<harmMean(resist, numPts)<<endl;

sortValues(resist, numPts);

cout<<"The sorted list of values is:";

for(int i = 0; i < numPts; i++)
{
cout<<resist[i]<<endl;
i++;
}

infile.close();
return 0;
}


int loadArray(ifstream& infile, double data[], int arrayLimit)
{
int numPts = 0;
while(numPts < arrayLimit && infile>>data[numPts])
{
numPts++;
}

if(numPts >= arrayLimit)
{
cout<<"Maximum number of data values reached"<<endl;
}
else if(!infile.eof())
{
cout<<"Error reading file"<<endl;
}
else
{
cout<<"End of file found"<<endl;
}

return numPts;
}

int findMax(resist, numPts)
{
if(numPts[i] >= MAXSIZE)
{
MAXSIZE = numPts[i];
}

return MAXSIZE;
}

int findMin(resist, numPts)
{

}

int calcMean(resist, numPts)
{

}

int geomMean(resist, numPts)
{

}

int rmsAvg(resist, numPts)
{

}

int harmMean(resist, numPts)
{

}

void sortValues(int resist, int numPts)
{

}
closed account (48T7M4Gy)
Your teacher wants you to fill in the blank lines. It's against the rules for anyone here to do that.
http://www.cplusplus.com/forum/general/178977/
Last edited on
it would be easier to do what you are trying if you just made all the variables global.
closed account (N7GEwA7f)
I wasnt trying to get anyone to do it for me i was just stuck and needed help. I filled everything out to the best of my ability and made other post because im not getting the answers i need.
there are an amazing amount of errors in this code...
closed account (N7GEwA7f)
How do i make all the variables global? and what errors?
You know that you can google Global variables and get your question answered within seconds, instead of posting the question here and wasting your and our time right?
why do you report him? He has legitimate logic.
Last edited on
Topic archived. No new replies allowed.