Today, we will learn how to calculate the volume of a cylinder in C Programming. We are referring to an awesome book called “Let Us C” by “Yashwant Kanetkar“. Hence, please come back to our portal regularly so that you don’t miss anything. If you have any problems with the program or need any assistance, don’t hesitate to write to us. We try to answer as quickly as possible.

## Question:

Accept the values of radius and height of the cylinder and write a program to calculate it’s volume.

## Solution to calculate the volume of cylinder in C:

Calculating the volume of a cylinder in C is very easy provided you know the formula. Let’s take a look at the algorithm:

- Accept the values of radius and height of the cylinder from the user.
- Calculate the volume using the formula – pi*r*r*h
- Output the volume

Here, we first initialise all the variables and set the value of pi to 3.14. Make sure that all the values are of the floating datatype or you won’t get accurate results. Then, ask the user to input the radius and height of the cylinder. Then calculate the answer and output the result back to the user.

### Download the source code:

Download Program## Program to calculate the volume of the cylinder in C:

//C Program to calculate the volume of a cylinder. #include "stdio.h" #include "conio.h" void main() { float pi=3.14, radius, height , volume; clrscr(); printf("Enter the radius and height of the cylinder: "); scanf("%f%f",&radius,&height); volume=pi*radius*radius*height; printf("The volume of cylinder is: %f",volume); getch(); }

## Output

Enter the radius and height of the cylinder: 4 5

The volume of the cylinder is 251.2

### Download the source code:

Please don’t forget to subscribe to us before you hit the download button! It helps us grow and provide more content.

Download Program## Read Also:

Check if the number is Odd or Even in C

How to Calculate Simple Interest in C Programming