In this post, we will know** how to calculate the volume of a cube using C** Programming language.

**Volume of a Cube **is the total cubic units occupied by it, in a three dimensional space.

**Volume of Cube = a x a x a = a**^{3}

We will be using the above technique in our program to compute the volume of a cube.

So, without further ado, let’s begin this tutorial.

**C Program to Calculate Volume of Cube**

// C Program to Calculate Volume of a Cube #include <stdio.h> int main(){ int side; long volume; // Asking for input printf("Enter the side of the cube: "); scanf("%d", &side); // Calculating Volume volume = side * side * side; // Displaying output printf("Volume of Cube: %ld", volume); return 0; }

**Output**

```
Enter the side of the cube: 8
Volume of Cube: 512
```

**How Does This Program Work ?**

int side; long volume;

In this program, we have declared one **int data type** variable and one **long data type** variable.

// Asking for input printf("Enter the side of the cube: "); scanf("%d", &side);

Then, the user is asked to enter the** side** of the cube.

// Calculating Volume volume = side * side * side;

We calculate the volume using the formula,** volume = a ^{3}**, where a is the side of the cube.

// Displaying output printf("Volume of Cube: %ld", volume);

Finally, the volume of the cube is printed on the screen using** printf()** function.

**Conclusion**

I hope after going through this post, you understand **how to calculate the volume of a cube using C** Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

**Also Read:**