Solved

error c2664: I am having problem with my code

Posted on 2011-03-13
2
329 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:pgmerLA
2 Comments
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 35124219
At first glance, on line 25 you have defined a variable called man (instead of max)
0
 

Author Comment

by:pgmerLA
ID: 35124277
Thanks a lot. I had been staring at the code for too long.
It works now.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maze travler 6 55
How do I add zip/compression functionality to a C++ (Windows and Linux) application? 3 107
C++ Language error 28 218
Issues with C++ Class 19 92
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question