HOME

Monday, September 7, 2015

FUNCTION OVERLOADING SAMPLE PROGRAM

#include<iostream>
using namespace std;
int volume(int);
int volume(int, int, int);
void volume(float, float);
int main()
{
    int s;
    cout<<"Enter size of cube"<<endl;
    cin>>s;
    cout<<"Volume of cube is "<<volume(s)<<endl;
    int l,b,h;
    cout<<"Enter the length, height and width of cuboid"<<endl;
    cin>>l>>b>>h;
    cout<<"Volume of cuboid is "<<volume(l,b,h)<<endl;
    float r,h1;
    cout<<"Enter the radius and height of cylinder"<<endl;
    cin>>r>>h1;
    volume(r,h1);
    return 0;
}
int volume(int l)
{
    return l*l*l;
}
int volume(int l,int b,int h)
{
    return (l*b*h);
}
void volume(float r, float h)
{
    float result;
    result=3.14*r*r*h;
    cout<<"Volume of cylinder is "<<result<<endl;
}

No comments:

Post a Comment