-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCuboidVolume.cpp
More file actions
32 lines (24 loc) · 888 Bytes
/
CuboidVolume.cpp
File metadata and controls
32 lines (24 loc) · 888 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
/* Write a C++ program to calculate the volume of a cuboid given its length, width and height.
Use the formula: Volume of a cuboid = l × b × h */
#include <iostream>
#include<cmath>
using namespace std;
// define the main function
int main()
{
// declare variables for length, width, height and volume
double length, width, height, volume;
// prompt the user to enter the length, width and height
cout << "Enter the length of the cuboid: ";
cin >> length;
cout << "Enter the width of the cuboid: ";
cin >> width;
cout << "Enter the height of the cuboid: ";
cin >> height;
// calculate the volume using the formula
volume = length * width * height;
// display the result
cout << "The volume of the cuboid is: " << volume << endl;
// return 0 to indicate successful execution
return 0;
}