-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathq-2.cpp
79 lines (60 loc) · 2.13 KB
/
q-2.cpp
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//WAP to find the volume of a sphere,Cylinder and a Cuboid using the function overloading concept
#include <iostream>
using namespace std;
int volume(int rad) //this function returns the VOLUME of SPHERE
{
return((4*3.14*r1*r1*r1)/3);
}
//cylinder
float volume(int r,int h)
return(3.14*r*r*h);
}
//cuboid
float volume(float l,float w,float h)
{
return (l*w*h);
}
int main()
{
float r,h,l,w;
int ch;
do
{
cout<<"\n Enter.. to find \n";
cout<<"\n 1. volume of sphere";
cout<<"\n 2. volume of cylinder";
cout<<"\n 3. volume of cube";
cout<<"\n 4. Exit from the program ";
cout<<"\n\n Enter Your Choice : ";
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"\n enter the radius for sphere: ";
cin>>r;
cout<<"\n volume of sphere is : "<<volume(r);
break;
}
case 2:
{
cout<<"\n enter the radius & height of cylinder : ";
cin>>r>>h;
cout<<"\n volume of cylinder is : "<<volume(r,h);
break;
}
case 3:
{
cout<<"\n enter the length, width and height for the cuboid : ";
cin>>l>>w>>h;
cout<<"\n volume of cuboid : "<<volume(l,w,h);
break;
}
case 4:
exit(0);
default:
cout<<"\n enter a valid choice ";
}
}while(ch!=4);
return 0;
}