-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunctionoverloading.cpp
More file actions
40 lines (30 loc) · 1002 Bytes
/
functionoverloading.cpp
File metadata and controls
40 lines (30 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
using namespace std;
float volume(float radius, float height){
return ((3.14)*radius*radius*height) ;
}
float volume(float radius, double height){
return ((3.14)*radius*radius*(height/3)) ;
}
float volume(float radius){
return ((1.33)*(3.14)*radius*radius*radius) ;
}
int main(){
float sphereRadius,coneRadius,cylinderRadius,cylinderHeight;
double coneSlantHeight;
cout<<"Enter the radius of Sphere : ";
cin>>sphereRadius;
cout<<"Enter the radius of Cone : ";
cin>>coneRadius;
cout<<"Enter the Slant height of Cone : ";
cin>>coneSlantHeight;
cout<<"Enter the radius of Cylinder : ";
cin>>cylinderRadius;
cout<<"Enter the height of Cylinder : ";
cin>>cylinderHeight;
cout<<"\nVolume of Sphere : " << volume(sphereRadius);
cout<<"\nVolume of Cone : " << volume(coneRadius,coneSlantHeight);
cout<<"\nVolume of Cylinder : " << volume(cylinderRadius,cylinderHeight);
cout<<endl;
system("pause");
}