Solved

# How do I send these values to another function?

Posted on 2003-03-24

Hello Guys.

I need to return the variable (getValues and max) to AboveandBelow()or to Main, The objective is to send it to AboveandBelow(). The Code is below. Thanks in Advance.

#include <iostream>

#include <iomanip>

using namespace std;

typedef int *myPointer;

int CheckErrors(int max); //Function prototype

int ReadData(void); //Function prototype

int * AboveAndBelow(int *underaHundred, int); //Function prototype

void PrintData(int *); //Function prototype

const int MAX = 100;

const int MIN = 1;

int main()

{

int values = 3;

int *findings = new int [values];

findings = AboveAndBelow(getValues, max);

ReadData();

PrintData(findings);

delete []findings;

return 0;

}

int CheckErrors(int max) //Definiton for CheckErrors

{

if(max < 1)

{

cout<<"Error: input "<<max<<" is too small"<<endl;

return 1;

}

if(max>100)

{

cout<<"Error:input "<<max<<" is too large"<<endl;

return 1;

}

return 0;

}

int ReadData(void) //Definition for ReadData

{

int max;

cout<<"HOW MANY NUMBERS DO YOU WANT TO ENTER?:\n"

<<"You can not enter more than 100 integers!!\n";

cin>>max;

while ((max > MAX) || (max < MIN))

{

cin>>max;

CheckErrors(max);

}

cout<<endl;

cout<<"Enter "<<max<<" numbers, separated by a space and end with ENTER:\n";

myPointer getValues;

getValues = new int [max];

for(int count = 0; count < max; count++)

{

cin >> getValues[count];

}

delete []getValues;

return 0;

}

int * AboveAndBelow(int *status, int max) //Definition for AboveandBelow

{

int under = 0;

int over = 0;

int equiv = 0;

int results = 3;

int count = 0;

int * answer = new int [results];

for(status; count < max; count++)

{

if((*(status+count) < 100))

{

under++;

}

if((*(status+count) > 100))

{

over++;

}

if((*(status+count) == 100))

{

equiv++;

}

answer[0] = under;

answer[1] = over;

answer[2] = equiv;

}

return answer;

}

void PrintData(int *result) //Definition for PrintData

{

cout<<endl;

cout<<" ---------------------------------------------------"<<endl;

cout<<" |Your Results According to the Integers You Entered|"<<endl;

cout<<" |";

cout<<"--------------------------------------------------|"<<endl;

cout<<" |There were "<<*(result+1)<<" Integers above a Hundred |"<<endl;

cout<<" |There were "<<*(result)<<" Integers under a Hundred |"<<endl;

if((*(result+2)))

{

cout<<" |There were "<<*(result+2)<<" Integer(s) equal Hundred |"<<endl;

}

cout<<" |==================================================|"<<endl;

cout<<" |==================================================|"<<endl;

cout<<endl;

}