-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP2.cpp
More file actions
74 lines (57 loc) · 2.05 KB
/
P2.cpp
File metadata and controls
74 lines (57 loc) · 2.05 KB
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
#include <iostream>
using namespace std;
int main(){
//--------------------------------------------Calculator----------------------------------------------------
// double num1, num2;
// char op;
// cout << "Enter first number: ";
// cin >> num1;
// cout << "Enter operator ";
// cin >> op;
// cout << "Enter second number: ";
// cin >> num2;
// switch (op) {
// case '+':
// cout << "Result = " << num1 + num2;
// break;
// case '-':
// cout << "Result = " << num1 - num2;
// break;
// case '*':
// cout << "Result = " << num1 * num2;
// break;
// case '/':
// if (num2 != 0)
// cout << "Result = " << num1 / num2;
// else
// cout << "Error: Division by zero not allowed";
// break;
// default:
// cout << "Invalid operator";
// }
// return 0;
//------------------------------------------Volume/Areas-----------------------------------------------
float side, radius, height, length, breadth;
float volumeCube, volumeCylinder;
float areaTriangle, areaRectangle;
cout << "Enter side of cube: ";
cin >> side;
volumeCube = side * side * side;
cout << "Volume of Cube = " << volumeCube << endl;
cout << "Enter radius of cylinder: ";
cin >> radius;
cout << "Enter height of cylinder: ";
cin >> height;
volumeCylinder = 3.14 * radius * radius * height;
cout << "Volume of Cylinder = " << volumeCylinder << endl;
cout << "Enter side of equilateral triangle: ";
cin >> side;
areaTriangle = (1.73 * side * side) / 4;
cout << "Area of Equilateral Triangle = " << areaTriangle << endl;
cout << "Enter length of rectangle: ";
cin >> length;
cout << "Enter breadth of rectangle: ";
cin >> breadth;
areaRectangle = length * breadth;
cout << "Area of Rectangle = " << areaRectangle << endl;
}