9 : C Program to Calculate Volume of Cube

Check out the complete list of c-programs : C Program List    

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

Variables :

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

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

Functions :

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

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

Formula :

Volume of Cube : (side)3

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

#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 best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.