Link to home
Start Free TrialLog in
Avatar of pgmerLA
pgmerLA

asked on

error c2664: I am having problem with my code

Hi, I am having trouble with my code.

Could you please tell me why it doesn't compile?

Thanks a lot.
#include<iostream>
#include<iomanip>

using namespace std;
const int N=6;

void ReadData(int x[]);
void Display (int x[]);
float FindAve(int x[]);
void DisplayAbove(int x[], float);
void FindMaxMin(int x[], int& max, int& min);

int main(){
	int a[N];
	//read data into array a
		ReadData(a);
	//Display array a
		Display(a);
	//find and display the average of numbers of array a
		float Average=FindAve(a);
		cout<<"Average= "<<fixed<<setprecision(2)<<Average<<endl;
	//Display data numbers whose value is >= average
		DisplayAbove(a,Average);
	//find and display the maximum and minimum numbers in array a
		int man, min;
		FindMaxMin(a,max,min);
		cout<<"The maximum data is "<<max<<endl;
		cout<<"The minimum data is "<<min<<endl;
	//terminate program
		return 0;
}
//--------------------------------------------------------------------------------
//Name:ReadData
//Input:numbers entered by the user
//Output:numbers stored in the array a
//--------------------------------------------------------------------------------
void ReadData(int x[])
{cout<<"Enter 6 integer numbers: ";
for( int i=0; i<N; ++i)
	cin>>x[i];
}
//--------------------------------------------------------------------------------
//Name:Display
//Input:array a
//Output:display the content of the array
//--------------------------------------------------------------------------------
void Display(int x[])
{cout<<"This is the content of the array a: ";
for(int i =0;i<N;++i)
cout<<x[i]<<' ';
cout<<endl;
}
//--------------------------------------------------------------------------------
//Name:FindAve
//Input:the array numbers
//Output:their average
//--------------------------------------------------------------------------------
float FindAve(int x[])
{float sum=0.0;
for(int i=0;i<N;++i)
sum+=x[i];
return sum/N;
}
//--------------------------------------------------------------------------------
//Name:DisplayAbove
//Input:array a and the average of the array
//Output:the numbers from the array which are above the average of the array
//--------------------------------------------------------------------------------
void DisplayAbove(int x[],float a)
{cout<<"This is the list of data whose values are above the average: ";
	for(int i=0;i<N;++i)
	{if (x[i]> a) cout<<x[i]<<' ';}
	cout<<endl;
}
//--------------------------------------------------------------------------------
//Name:FindMaxMin
//Input:array a
//Output:the max and min number from the array
//--------------------------------------------------------------------------------
void FindMaxMin(int x[],int& max, int& min)
{max=min=x[0];
for(int i=1;i<N;++i)
	{if(x[i]>max) max=x[i];
	if(x[i]<min) min=x[i];
	}
}

/*--------------------------------------------------------------------------------
Input: enter 22 33 44 11 88 77
--------------------------------------------------------------------------------*/

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pgmerLA
pgmerLA

ASKER

Thanks a lot. I had been staring at the code for too long.
It works now.