In this article we will show you, How to write C Program to find Volume and Surface Area of a Cylinder with example. Before we step into the program, Let see the definitions and formulas behind Surface Area of a Cylinder, Lateral Surface Area, Top or Bottom Surface Area and Volume of a Cylinder.

### Surface Area of a Cylinder

If we know the radius and height of the cylinder then we can calculate the surface area of a cylinder using the formula:

- Surface Area of a Cylinder = 2πr² + 2πrh (Where r is radius and h is the height of the cylinder).

**Volume of a Cylinder:** The amount of space inside the Cylinder is called as Volume.** **If we know the height of a cylinder then we can calculate the Volume of a cylinder using formula:

- Volume of a Cylinder = πr²h
- The Lateral Surface Area of a Cylinder = 2πrh
- We can calculate the Top Or Bottom Surface Area of a Cylinder = πr²

## C Program to find Volume and Surface Area of a Cylinder

This C program allows the user to enter the value of a radius and height. Using these values, it will calculate the Volume of a Cylinder, Surface Area of a Cylinder, Lateral Surface Area of a Cylinder, Top Or Bottom Surface Area of a Cylinder as per the formula.

**CODE**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* C Program to find Volume and Surface Area of a Cylinder */ #include<stdio.h> #include<math.h> int main() { float radius, height; // L = Lateral Surface Area of a Cylinder, T = Top Surface Area float sa,Volume, L, T; printf("\n Please Enter the radius and height of a cylinder \n"); scanf("%f %f", &radius, &height); sa = 2 * M_PI * radius * (radius + height); Volume = M_PI * radius * radius * height; L = 2 * M_PI * radius * height; T = M_PI * radius * radius; printf("\n Surface Area of a cylinder = %.2f", sa); printf("\n Volume of a Cylinder = %.2f", Volume); printf("\n Lateral Surface Area of a cylinder = %.2f", L); printf("\n Top OR Bottom Surface Area of a cylinder = %.2f", T); return 0; } |

**NOTE:** If you fail to include math.h header file then M_PI will through an error. We can also define pi as global or local variable and assign value as 3.14.

**OUTPUT**

We have entered the radius of a Cylinder = 3 and height = 5

The Surface Area of a Cylinder is

Surface Area of a Cylinder= 2πr² + 2πrh

It can also be written as

Surface Area of a Cylinder = 2πr (r+h)

Surface Area of a Cylinder = 2 * M_PI * radius * (radius + height)

Surface Area of a Cylinder = 2 * 3.14 * 3 * (3+5);

Surface Area of a Cylinder = 150.72

The Volume of a Cylinder is

Volume of a Cylinder = πr²h

Volume of a Cylinder = M_PI * radius * radius * height

Volume of a Cylinder = 3.14 * 3 * 3 * 5

Volume of a Cylinder = 141.3

The Lateral Surface Area of a Cylinder is

L = 2πrh

L = 2 * M_PI * radius * height

L = 2 * 3.14 * 3 * 5

L = 94.2

The Top Or Bottom Surface Area of a Cylinder is

T = πr²

T = M_PI * radius * radius

T = 3.14 * 3 * 3

T = 28.26

**NOTE:** For the calculation purpose we have taken π = 3.14 instead of (3.142857142..). So, All the above values are almost equal to program output but may differ at 0.01.

Thank you for Visiting Our Blog

## Leave a Reply