/*
Definition :Write a C++ program for overloading
a function volume() to calculate the
volume of cube, cylinder and a rectangular
box. Where volume of
Cube=a*a*a
Cylinder= 3.14*r*h
Rectangular box=l*b*h
Tut. Date :
Lab Date :
*/
#include<iostream.h>
#include<conio.h>
class Vol
{
public:
void volume(int a)
{
cout<<endl<<"Volume of Cube : "<<a*a*a;
}
void volume(int r,int h)
{
cout<<endl<<"Volume of Cylinder : "<<3.14*r*h;
}
void volume(int l,int b, int h)
{
cout<<endl<<"Volume of Rectangle : "<<l*b*h;
}
};
int main()
{
clrscr();
Vol v;
int a,r,l,b,h;
cout<<"Enter a : ";
cin>>a;
cout<<"Enter r : ";
cin>>r;
cout<<"Enter h : ";
cin>>h;
cout<<"Enter l : ";
cin>>l;
cout<<"Enter b : ";
cin>>b;
v.volume(a);
v.volume(r,h);
v.volume(l,b,h);
getch();
return 0;
}
No comments:
Post a Comment