Skip to main content

C++ Program to calculate the volume of cube,cylinder and rectangle using function overloading.

#include<iostream.h>
#include<conio.h>

int volume(int);
double vlume(double,int);
long volume(long,int,int);

int main()
{
clrscr();
cout<<"Volume of a Cube:"<<volume(11)<<endl;
cout<<"Volume of a Cylinder:"<<volume(3.2,5)<<endl;
cout<<"Volume of Rectangle:"<<volume(185,15,5)<<endl;
getch();
return 0;
}

int volume(int s);
{
return(s*s*s);
}

double volume(double r,int h)
{
return(3.14285*r*r*h);
}

long volume(long l,int b,int h){
return(l*b*h);
}

Output:

Volume of Cube:1331

Volume of Cylinder:161.033728

Volume of Rectangle:13875

Comments

Post a Comment