Hi!
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 me..here is my code
#include<iostream.h>
#include<conio.h>
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()
{clrscr();
int num1,num2,num3,num4,max,min;
cout<<"Input 4 integer values"<<endl;
cin>>num1>>num2>>num3>>num4;
max(num1,num2,num3,num4);
min(num1,num2,num3,num4);
getch();
}
void max(int a,int b,int c,int d)
{ max_val=a;
if (b>max_val)
max_val=b;
if (c>max_val)
max_val=c;
if (d>max_val)
max_val=d;
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)
min_val=b;
if (c<min_val)
min_val=c;
if (d<min_val)
min_val=d;
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
#include<iostream.h>
#include<conio.h>
float avg(int a,int b,int c,int d);
void main()
{clrscr();
int w,x,y,z;
float avg;
cout<<"Input four numbers"<<endl;
cin>>w>>x>>y>>z;
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;
p=(a+b+c+d)/4;
return p;
}
plz help me find my error
thx alot