Calculate Volume of Cube

To calculate the volume of Cube you need to know the side of the cube.


1. side : (Datatype int) : to represent the side a cube.

2. volume_of_cube : (Datatype long) : to store the volume of cube result.


printf() : is used to display something on the console/screen. Format specifier %d in printf function is used to display an int variable on screen and %ld for long. \n is used to add a new line

scanf(): is used to fetch data inputted by the user on the console/screen using the keyboard. %d in scanf is indicated that inputted text is of type int and %ld for long.

 * 1000+ C programs + tutorials
 * 9_calculate_volume_of_cube.c
 *  Created on: Oct 20, 2014
 *  Author:

#include <stdio.h>
//#include <conio.h>

void main() {

    int side;
	long volume_of_cube;

//	clrscr();

	printf(" Program to calculate Volume of a Cube :  \n\n");

	printf(" Enter the side of cube : ");
	scanf("%d", &side);
	volume_of_cube = side*side*side;

	printf("\n\n Volume of Cube with Side as %d = %ld ",side, volume_of_cube);

//	getch();


The volume of Cube : (side)3

Program to calculate Volume of a Cube:
Enter the side of the cube: 40
The volume of Cube with Side as 40 = 64000

Program to calculate Volume of a Cube:
Enter the side of the cube: 10
The volume of Cube with Side as 10 = 1000
Try Out Code2care Dev Tools:


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.