Write a C++ Program to Find the Volume and Surface Area of a Cube with an example. This C++ program allows users to enter the length of any side of a cube. Next, we calculate the Surface Area, Lateral Surface Area, and Volume of a cube using mathematical formulas. They are
- C++ Volume of a Cube = l * l * l
- C++ Surface Area of a Cube = 6l²
- C++ Lateral Surface Area of a Cube = 4 * (l * l)
#include<iostream> #include <cmath> using namespace std; int main() { float cu_len, cu_sa, cu_Volume, cu_LSA; cout << "\nPlease Enter the Length of any side of a Cube = "; cin >> cu_len; cu_sa = 6 * (cu_len * cu_len); cu_Volume = cu_len * cu_len * cu_len; cu_LSA = 4 * (cu_len * cu_len); cout << "\nThe Surface Area of a Cube = " << cu_sa; cout << "\nThe Volume of a Cube = " << cu_Volume; cout << "\nThe Lateral Surface Area of a Cube = " << cu_LSA; return 0; }