C++ that finds the volume of different shapes using function overloading

/*1. Write a program in C++ that finds the volume of
different shapes box(like rectangle, cylinder, cube)
using function overloading.*/
#include<iostream>
using namespace std;
int volume(int);
long volume(long,int,int);
double volume (double, int);
int main()
{ cout << volume(10) <<endl; //cube
cout << volume(3,8) <<endl; // cylinder
cout << volume(10,70,10) <<endl; //rectangle
return 0;
}
// function definition//
int volume (int s) //cube
{
return (s*s*s);
}
double volume (double r, int h) //cylinder
{
return (3.14519*r*r*h);
}
long volume (long l, int b, int h) //rectangular box
{
return (l*b*h);
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>