C Programming Code Examples C > Mathematics Code Examples C Program to Compute the Surface Area & Volume of a Cube C Program to Compute the Surface Area & Volume of a Cube This C Program computes the surface area & volume of a cube. The formula used to find the surface area and volume of the cube is surface_area = 6 * (a * a) and volume = a * a * a. #include <stdio.h> #include <math.h> void main() { float side, surfacearea, volume; printf("Enter the length of a side \n"); scanf("%f", &side); surfacearea = 6.0 * side * side; volume = pow(side, 3); printf("Surface area = %6.2f and Volume = %6.2f \n", surfacearea, volume); } In this C program, library function is used in header file to compute mathematical functions. We are entering the length of a side using side variable. Now to find the surface area of a cube the formula, surface area = 6 *(side * side) is used. Then, to find the volume of a cube the formula, volume = pow(side,3) is used. Here, the program uses power function defined in math library. Finally, the surface area and volume will be displayed in the standard output.