- Write a C program to find volume of a cube.
- Write a C program to find total surface area of a cube.

A cube is a three dimensional object having equal width, height, and length measurements. A cube has twelve edges, six square faces and eight vertices. The cube can also be called a regular hexahedron.

Each face of a cube is a square of same side length and angle between all adjacent faces are 90^{.}. At each vertex, three square faces of cube meet at right angle.

For Example : A dice is a cube.

**Volume of Cube**

The volume of a cube can be defined as the amount of three dimentional space occupied by the cube. Volume of a cube is the number of cubic units that will exactly fill a cube. The volume of a cube is measured in cubic units like cm

^{3}, m

^{3}etc.

To calculate the volume of a cube we should know the length of any side of cube because for a cube the measure of all three dimensions are exactly the same. Therefore, you can multiply the length of any side three times to get the volume.

**Volume of Cube = Side X Side X Side = Side**^{3}

**Total Surface Area of Cube**

The total surface area of cube is the total area on the outer side of a cube. In other words, we can think surface area of a cube as the total external surface we should paint to colour a cube.

As we know that, a cube has six square surfaces of equal dimentions. Hence, to find the total surface of a cube first of all we should find the area of one square surface and the multiply it with 6 to get total surface area of cube.

**Area of a Face of Cube = Side X Side****Total Surface area of Cube = 6 X Side X Side**

## C Program to find total surface area of a cube

To calculate the surface area of a cube we need the length of any side of a cube. Below program first takes length of side as input from user using scanf function and stores it in a floating point variable 'side'. In line number 12, it calculates the surface area as 6*side*side and stores the result in a floating point variable 'surfaceArea'. Finally, it prints the total surface area of cube on screen using printf function.

/* * C Program to calculate total surface area of Cube */ #include <stdio.h> #include <conio.h> int main(){ float side, surfaceArea; printf("Enter length of any side of cube\n"); scanf("%f", &side); /* Total surface area of Cube = 6 X side X side */ surfaceArea = 6*side*side; printf("Total surface area of Cube : %0.4f\n", surfaceArea); getch(); return 0; }

**Program Output**

Enter length of any side of cube 7.3 Total surface area of Cube : 319.7400

## C Program to calculate volume of a cube

To find the volume of a cube we need the length of any side of cube. Below program first takes length of side as input from user using scanf and stores it in a floating point variable 'side'. In line number 12, it calculates the volume of cube as side*side*side and stores the result in a variable 'volume'. Finally, it prints the total surface area of cube on screen using printf.

/* * C Program to calculate volume of Cube */ #include <stdio.h> #include <conio.h> int main(){ float side, volume; printf("Enter length of any side of cube\n"); scanf("%f", &side); /* Volume of Cube = side X side X side */ volume = side*side*side; printf("Volume of Cube : %0.4f\n", volume); getch(); return 0; }

**Program Output**

Enter length of any side of cube 7.3 Volume of Cube : 389.0170

**Properties of Cube**

- All twelve edges of a cube are of same length.
- A cube has six identical square faces of same dimensions.
- The angle between any two edge of a cube is 90
^{.}. - Opposite faces of a cube are parallel.
- All three faces meeting at a vertex are mutually perpendicular.
- A face of a cube touches four other faces.
- A cube is a special case of cuboid, where length, width and height are equal.
- The length of the face diagonal of a cube is √2 times the length of side.
- The length of major body diagonal of cube is √3 times the length of side.

**Related Topics**