#include<conio.h>
#include <iostream.h>
class FunABS
{
public:
int abs(int n)
{
cout<<"\n In Integer fuction "<< endl;
if(n<0)
return -n;
else
return n;
}
float abs(float n)
{
cout<<" \n In float fuction "<< endl;
if(n<0)
return -n;
else
return n;
}
};
int main()
{
// create object of FunABS class
FunABS ob;
int a=10,b;
float pi=3.142f,k;
clrscr();
b=ob.abs(a);
cout<<" b= "<<b;
k=ob.abs(pi);
cout<<" k= "<<k;
return 0;
}
OUTPUT:
0 Comments
Post a Comment