State the output Function Overloading 2

/*
    State the output
*/
#include<iostream>
using namespace std;

int absolute(int);
float absolute(float);

int main()
{
    int a=-5;
    float b=5.5;

    cout<<"\n Absolute value of "<<a<<" = "<<absolute(a);
    cout<<"\n Absolute value of "<<b<<" = "<<absolute(b);

    return 0;
}

int absolute(int var)
{
    if(var<0)
        var=-var;
    return var;
}
float absolute(float var)
{
    if(var<0.0)
        var=-var;
    return var;
}

Previous
Next Post »