-
Notifications
You must be signed in to change notification settings - Fork 0
/
q3 Cylinder volume.txt
50 lines (38 loc) · 1.2 KB
/
q3 Cylinder volume.txt
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
#include<iostream>
using namespace std;
class Cylinder{
// creating private member variables
private: int radius,height;
public:
// using set() to assign the value to the private variables
set(int x,int y)
{
radius=x;
height=y;
}
// running that getVolume() funvtion using Get()
get()
{
getvolume();
}
// creating getvolume function to calculate the volume of Cylinder
int getvolume()
{
cout<<"volume of Cylinder is :";
// storing the calulation of volume of Cylinder inside the Volume variable
int volume=3.14159*radius*radius*height;
return volume;
}
};
int main()
{
//creating two variable to store the radius and height value inside it.
int a,b;
cout<<"please enter the radius value of Cylinder: ";
cin>>a;// getting radius input from user
cout<<"please enter the height value of Cylinder: ";
cin>>b;// getting height input from user
Cylinder obj;// creating an object of class
obj.set(a,b);//setting values to the radius and height private members using set() function
cout<<obj.get(); //getting output usingt get() function.
}