Power By Dholu Production

Responsive Ads Here

Tuesday, April 24, 2018

Write a prg to implement function overloading and return volume of cube, cylinder, rectangular box|C++


#include<iostream>
using namespace std;

float vol(float);
float vol(float, float);
float vol(float, float, float);

float vol(float a)
{
    return(a*a*a);
}
float vol(float R, float H)
{
    return(3.14*R*R*H);
}
float vol(float L, float B, float H1)
{
    return(L*B*H1);
}

int main()
{
    float x,y,z,o,p,q;
    cout<<"\n Enter value A for cube:";
    cin>>x;
    cout<<"\n Ans:"<<vol(x);
    cout<<"\n Enter value R for cylinder:";
    cin>>y;
    cout<<"H:";
    cin>>z;
    cout<<"Ans:"<<vol(y,z);
    cout<<"\n Enter value L for Rectangle:";
    cin>>0;
    cout<<"B:";
    cin>>p;
    cout<<"H1:";
    cin>>q;
    cout<<"Ans:"<<vol(o,p,q);
    return 0;
}