FUNCTION OVERLOADING
AIM:- To write a C++ program to find the volume using function overloading concept.
ALGORITHM:
1. Start the program
2. Include suitable header file
3. Declare the function of same name with different parameter
4. Define the function for calculating the volume
5. Call the respective functions
6. Print the volume
7. Stop the program
CODING:
#include<iostream.h>
#include<conio.h>
int volume(int);
double volume(double,int);
long volume(long,int,int);
int main()
{
clrscr();
cout<<”volume of cube=”;
cout<<volume(10)<<"\n";
cout<<”volume of cylinder=”;
cout<<volume(2.5,8)<<"\n";
cout<<”volume of cubiod=”;
cout<<volume(100,75,15)<<"\n";
return 0;
getch();
}
int volume(int s)
{
return(s*s*s);
}
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 of cube = 1000
volume of cylinder = 15700
volume of cubiod = 112500
RESULT:
- Thus to write a C++ program to find the volume using function overloading concept was successfully completed.
0 comments:
Post a Comment