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; ` `} ` |

*chevron_right*

*filter_none*

## 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. ` |

*chevron_right*

*filter_none*

## 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". ` |

*chevron_right*

*filter_none*

## 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. ` |

*chevron_right*

*filter_none*

## 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. ` `?> ` |

*chevron_right*

*filter_none*

Output:

Area = 125 Total surface area = 150

This article is contributed by **Saloni Gupta **. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Program for Volume and Surface Area of Cuboid
- Program to calculate Volume and Surface area of Hemisphere
- Program for Volume and Surface area of Frustum of Cone
- Program to find volume and surface area of pentagonal prism
- Program to find Surface Area and Volume of Octagonal Prism
- Calculate Volume and Surface area Of Sphere
- Calculate volume and surface area of a cone
- Surface Area and Volume of Hexagonal Prism
- Calculate volume and surface area of Torus
- Percentage increase in volume of the cube if a side of cube is increased by a given percentage
- Program for Surface Area of Octahedron
- Program for Surface area of Dodecahedron
- Program to calculate the Surface Area of a Triangular Prism
- Program to find the surface area of the square pyramid
- Program to calculate area and volume of a Tetrahedron
- Program to find the Area and Volume of Icosahedron
- Volume of cube using its space diagonal
- Find the Surface area of a 3D figure
- Find maximum volume of a cuboid from the given perimeter and area