Welcome To The World Of Hacking


Learn Hacking|Teach Hacking|Learn To Secure|Learn To Code

Monday

C++ TUTORIAL 15: FUNCTION OVERLOADING

#include<iostream>
using namespace std;

//Function declaration
int volume(int);
double volume(double,int);
long volume(long,int,int);

int main()
{
    cout<<"Volume of Cube:"<<volume(8)<<endl;
    cout<<"Volume of Cylinder:"<<volume(3.3,7)<<endl;
    cout<<"Volume of Rectangular:"<<volume(200,98,50)<<endl;

    return 0;
}

//Function definition
int volume(int s) //cube
{
    return s*s*s;
}
double volume(double r,int h)//cylinder
{
    return 3.14*r*r*h;
}
long volume(long l,int b,int h)//rectangular
{
    return l*b*h;
}

OUTPUT:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...