13 : C Program to Calculate Volume of Cone

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

Variables :

1. height : (Datatype int) : to represent the height of Cone.

2. radius : (Datatype int) : to represent the radius of Cone.

3. PI : (Datatype float) : static variable to represent constant PI value upto 3 decimal places i.e 3.142

5. volume_of_cone : (Datatype float) : to store volume of Cone calculated.

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 %lf for float. \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 %f for float.

Formula :

Volume of a Cone : π x r2x h

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

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

void main() {

    int height;
    int radius;
    float volume_of_cone;
    float PI = 3.142;

//	clrscr();

	printf(" Program to calculate Volume of a Cone :  ");

	printf("\n\n Enter the Radius of Cone : ");
	scanf("%d", &radius);
    printf("\n\n Enter the Height of Cone : ");
	scanf("%d", &height);
    volume_of_cone = PI*radius*radius*height;

	printf("\n\n Volume of Cone with Radius as %d and Height as %d = %f",radius,height,volume_of_cone);

//	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.