Skip to content

C Program to Find the Volume of a Cube

Formula:
Volume of Cube = Side × Side × Side = side³

#include <stdio.h>

int main()
{
float side, volume;

printf(“Enter the side of the cube: “);
scanf(“%f”, &side);

volume = side * side * side;

printf(“Volume of cube = %.2f”, volume);

return 0;

}

Explanation

  • side stores the side length entered by the user.
  • volume = side * side * side calculates the cube’s volume.
  • %.2f displays the answer up to 2 decimal places.