By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,973 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,973 IT Pros & Developers. It's quick & easy.

error: call of a non function

P: 17
I'm suppode to write a prg to calculate maximum and minimum of 4 intergers by using functions
i've writen the code but getting the error: call of a non function..cant see my error help is my code

void max(int a,int b,int c,int d);
void min(int a,int b,int c,int d);
int num1,num2,num3,num4,max_val,min_val;
void main()
int num1,num2,num3,num4,max,min;
cout<<"Input 4 integer values"<<endl;




void max(int a,int b,int c,int d)
{ max_val=a;
if (b>max_val)
if (c>max_val)
if (d>max_val)
cout<<"The maximum integer value is:"<<max_val<<endl;

void min(int a,int b,int c,int d)
{ min_val=a;
if (b<min_val)
if (c<min_val)
if (d<min_val)
cout<<"The minimum integer value is:"<<min_val<<endl;

Same error when am dong another program for calculating the average of 4 integers..
here is my code

float avg(int a,int b,int c,int d);
void main()
int w,x,y,z;
float avg;
cout<<"Input four numbers"<<endl;
cout<<"The average of the four numbers is:"<<avg(w,x,y,z)<<endl;
float avg(int a,int b,int c,int d)
{float p;
return p;

plz help me find my error
thx alot
Nov 19 '06 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,510
in main() you define two local variables max and min which 'hide" the functions max() and min(), when you attempt to call the functions
Expand|Select|Wrap|Line Numbers
  1. max(num1,num2,num3,num4);
  2. min(num1,num2,num3,num4);
the compiler thinks you are calling the local variables as though they are functions

remove the max and min local variables and the program works.
Nov 19 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.