The program returns the absolute value of an argument.
#include<iostream.h>
void main( )
{
int i=-25,j;
long l=-100000L,m;
double d=-12.34,e;
int abs(int);
long abs(long);
double abs(double);
j=abs(i);
m=abs(l);
e=abs(d);
cout<<endl<<j<<endl<<m<<e;
}
int abs(int ii)
{
return(ii>0?ii:ii*-1);
}
long abs(long ll)
{
return(ll>0?ll:ll*-1);
}
double abs(double dd)
{
return(dd>0?dd:dd*-1);
}
Click here to read about Function Overloading
No comments:
Post a Comment