Program for Volume and Surface Area of Cube Last Updated : 16 Feb, 2023 Comments Improve Suggest changes 2 Likes Like Report Cube is a 3-dimensional box-like figure represented in the 3-dimensional plane. Cube has 6 squared-shape equal faces. Each face meet another face at 90 degree each. Three sides of cube meet at same vertex. Examples: Input : Side of a cube = 2 Output : Area = 8 Total surface area = 24 Input : Side of a cube = 3 Output : Area = 27 Total surface area = 54 Volume: a*a*a Total Surface area: 6*a*a C++ // CPP program to find area // and total surface area of cube #include <bits/stdc++.h> using namespace std; // utility function double areaCube(double a) { return (a * a * a); } double surfaceCube(double a) { return (6 * a * a); } // driver function int main() { double a = 5; cout << "Area = " << areaCube(a) << endl; cout << "Total surface area = " << surfaceCube(a); return 0; } Java // Java program to find area // and total surface area of cube class GFG { // utility function static double areaCube(double a) { return (a * a * a); } static double surfaceCube(double a) { return (6 * a * a); } // Driver code public static void main (String[] args) { double a = 5; System.out.println("Area = "+areaCube(a)); System.out.println("Total surface area = " +surfaceCube(a)); } } // This code is contributed by Anant Agarwal. Python3 # Python3 code to find area # and total surface area of cube # utility function def areaCube( a ): return (a * a * a) def surfaceCube( a ): return (6 * a * a) # driver function a = 5 print("Area =", areaCube(a)) print("Total surface area =", surfaceCube(a)) # This code is contributed by "Sharad_Bhardwaj". C# // C# program to find area // and total surface area of cube using System; class GFG { // utility function static double areaCube(double a) { return (a * a * a); } static double surfaceCube(double a) { return (6 * a * a); } // Driver code public static void Main() { double a = 5; Console.WriteLine("Area = " + areaCube(a)); Console.WriteLine("Total surface area = " + surfaceCube(a)); } } // This code is contributed by vt_m. PHP <?php // PHP program to find area // and total surface area of cube // utility function function areaCube($a) { return ($a * $a * $a); } function surfaceCube( $a) { return (6 * $a * $a); } // driver function $a = 5; echo ("Area = "); echo(areaCube($a)); echo("\n"); echo("Total surface area = "); echo(surfaceCube($a)); // This code is contributed by vt_m. ?> JavaScript <script> // javascript program to find area // and total surface area of cube // utility function function areaCube( a) { return (a * a * a); } function surfaceCube( a) { return (6 * a * a); } // Driver function let a = 5; document.write( "Area = " + areaCube(a) +"<br/>"); document.write( "Total surface area = " + surfaceCube(a)); // This code is contributed by gauravrajput1 </script> Output: Area = 125 Total surface area = 150 Time complexity : O(1) Auxiliary Space : O(1) Create Quiz Comment S Saloni Gupta 2 Improve S Saloni Gupta 2 Improve Article Tags : Misc Geometric DSA Basic Coding Problems area-volume-programs maths-cube +2 More Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 15 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 1 min read Problem of The Day - Develop the Habit of Coding 5 min read Like