C++ Program to demonstrate function overloading using function.

/*Program to demonstrate function overloading using function*/

#include<iostream.h>
#include<conio.h>
int volume(int a);                //function 1
double volume(int,double);        //function 2
long volume(long,int,long);       //function 3
void main()
{
clrscr();
cout<<"The volume of cube is:";     //Calling function 1
cout<<volume(5);
cout<<"\n The volume of cube is:";  //Calling function 3
cout<<volume(5l,3,4);
cout<<"\n The volume of cube is:";  //Calling function 2
cout<<volume(5.5,3);
getch();
}
int volume(int a)
{
return(a*a*a);
}
double volume(double r, int h)
{
return(3.14*r*r*h);
}
long volume (long l, int b,int h)
{
return(l*b*h);
}
Output:
Volume 125
Volume 51.81

Volume 60

Post a Comment

Previous Post Next Post