C++ Program to find Volume and Surface Area of a Cube

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;
}
C++ Program to find Volume and Surface Area of a Cube 1

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.