-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise03.cpp
More file actions
57 lines (44 loc) · 1.39 KB
/
exercise03.cpp
File metadata and controls
57 lines (44 loc) · 1.39 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
#include <iostream>
using namespace std;
// 1. Define a structure called Box
// have the integer data types Height, Width, Length
// Do not change the main function
int volume(int height, int width, int length);
struct box {
int height;
int width;
int length;
} ;
int main() {2
222
struct box box1;
struct box box2;
// 2. Create a variable called box1 of the Box structure type
// int box1Height, box1Width, box1Length;
// 3. Create a variable called box2 of the Box structure type
// int box2Height, box2Width, box2Length;
int totalVolume;
// 4. Input the height, width, lenght of box1 and box2
cout << "Enter Box 1 Height : ";
cin >> box1.height;
cout << "Enter Box 1 Width : ";
cin >> box1.width ;
cout << "Enter Box 1 Length : ";
cin >> box1.length;
cout << "Enter Box 2 Height : ";
cin >> box2.height;
cout << "Enter Box 2 Width : ";
cin >> box2.width ;
cout << "Enter Box 2 Length : ";
cin >> box2.length;
//5. Replace the coding below to pass the Box type structure
totalVolume = volume( box1.height,box1.width, box1.length )
+ volume( box2.height,box2.width, box2.length);
cout << "Volume of Box is " << totalVolume << endl;
return 0;
}
// Implement the functions here
int volume(int height, int width, int length){
int x = height * width * length;
return x;
}