Write a C++ Program to Find the Volume and Surface Area of a Cuboid with an example. This C++ program allows user to enter the length, width, and height of a cuboid. Next, we calculate the Surface Area, Volume, and Lateral Surface Area of a cuboid using mathematical formulas. They are
- C++ Volume of a Cuboid = lbh
- C++ Surface Area of a Cuboid = 2(lw + lh + wh)
- C++ Lateral Surface Area of a Cuboid = 2h(l + w)
Where l = length, b = breadth, h = height, and w = width
#include<iostream>
using namespace std;
int main()
{
float cbd_Length, cbd_Width, cbd_Height, cbd_sa, cbd_Volume, cbd_LSA;
cout << "\nPlease Enter the Length of a Cuboid = ";
cin >> cbd_Length;
cout << "\nPlease Enter the Width of a Cuboid = ";
cin >> cbd_Width;
cout << "\nPlease Enter the Height of a Cuboid = ";
cin >> cbd_Height;
cbd_sa = 2 * (cbd_Length * cbd_Width + cbd_Length * cbd_Height + cbd_Width * cbd_Height);
cbd_Volume = cbd_Length * cbd_Width * cbd_Height;
cbd_LSA = 2 * cbd_Height * (cbd_Length + cbd_Width);
cout << "\nThe Surface Area of a Cuboid = " << cbd_sa;
cout << "\nThe Volume of a Cuboid = " << cbd_Volume;
cout << "\nThe Lateral Surface Area of a Cuboid = " << cbd_LSA;
return 0;
}