HOME

Sunday, November 29, 2015

FUNCTION OVERLOADING

#include<iostream>
using namespace std;
int volume(int);
int volume(int, int , int);
int volume(int, int);
int main()
{
    int s,l,b,h1,h2,r;
    cout<<"Enter side of cube"<<endl;
    cin>>s;
    volume(s);
    cout<<"Enter radius and height of cylinder"<<endl;
    cin>>r>>h1;
    volume(r,h1);
    cout<<"enter length, breadth and height of cuboid"<<endl;
    cin>>l>>b>>h2;
    volume(l,b,h2);
    return 0;
}
int volume(int s)
{
int result1=s*s*s;
cout<<"volume of cube is "<<result1<<endl;
return 0;
}
int volume(int r,int h1)
{
    int result2=3.14*r*r*h1;
    cout<<"Volume of cylinder is "<<result2<<endl;
    return 0;
}
int volume(int l, int b, int h2)
{
    int result3=l*b*h2;
    cout<<"volume of cuboid is "<<result3<<endl;
    return 0;
}

No comments:

Post a Comment