How to write C Program to find Volume and Surface Area of a Cylinder with example?. Before we step into the C Program to find Volume and Surface Area of a Cylinder, Let see the definitions and formulas behind the Surface Area of a Cylinder, Lateral Surface Area, Top, or Bottom Surface Area and Volume of a Cylinder.

## C Surface Area of a Cylinder

If we know the radius and height of the cylinder, 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).

**The Volume of a Cylinder:** The amount of space inside the Cylinder called Volume. If we know the height of a cylinder then we can calculate the volume of a cylinder using the 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.

/* 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 the C Programming math.h header file, M_PI will throw an error. We can also define pi as a global or local variable and assign value as 3.14.

**OUTPUT**

In this C Program to find Volume and Surface Area of a Cylinder example, 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 C program values are almost equal to program output but may differ at 0.01.