18. Write a C++ program to find volume of cube, cylinder an rectangle using function overloading.


#include<iostream.h>
#include<conio.h>
const float pi=3.14;
float vol(float l) //Cube
{
return l*l*l;
}
float vol(float r,float h) //Cylinder
{
return (pi*r*r*h);
}
float vol(float l,float b,float h)
{
return (l*b*h);
}
void main()
{
float l,r,b,h,t;
clrscr();
cout<<“\nEnter the Length of Cube: \n”;
cin>>l;
t=vol(l);
cout<<“\n\nVolume of Cube: “<<t;
cout<<“\n\nEnter the Radius & Hieght of Cylinder: \n”;
cin>>r>>h;
t=vol(r,h);
cout<<“\n\nVolume of Cylinder: “<<t;
cout<<“\n\nEnter the Length,Breadth & Hieght of Rectangle: \n”;
cin>>l>>b>>h;
t=vol(l,b,h);
cout<<“\n\nVolume of Rectangle: “<<t;
getch();
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s