C Program to Find Volume and Surface Area of Cylinder

This is a C Program to find the volume and surface area of cylinder.

Problem Description

This C Program calculates volume and surface area of cylinder.

Problem Solution

The formula used in this program Surface_area = 2 * Pi * r * (r + h), Volume = Pi * r * r * h where Pi = 22/7.

Program/Source Code

Here is source code of the C Program to Find the volume and surface area of cylinder.The C program is successfully compiled and run on a Linux system. The program output is also shown below.

 * C Program to Find the Volume and Surface Area of cylinder
#include <stdio.h>
#include <math.h>
int main()
    float radius, height;
    float surface_area, volume;
    printf("Enter  value for  radius and height of a cylinder : \n");
    scanf("%f%f", &radius, &height);
    surface_area = 2 * (22 / 7) * radius * (radius + height);
    volume = (22 / 7) * radius * radius * height;
    printf("Surface area of cylinder is: %.3f", surface_area);
    printf("\n Volume of cylinder is : %.3f", volume);
    return 0;
Program Explanation

In this C program, library function defined in <math.h> header file is used to compute mathematical functions. We are reading the radius and height of a cylinder using ‘radius’ and ‘height’ variables respectively. To find the surface area and volume of a cylinder, the following formulas are used.
Surface area = 2 * (22 / 7) * radius * (radius + height)
Volume = (22 / 7) * radius * radius * height

Runtime Test Cases
$ cc pgm29.c -lm
$ a.out
Enter  value for  radius and height of a cylinder :
15 17
Surface area of cylinder is: 2880.000
Volume of cylinder is : 11475.000

Sanfoundry Global Education & Learning Series – 1000 C Programs.

Here’s the list of Best Books in C Programming, Data-Structures and Algorithms

Note: Join free Sanfoundry classes at Telegram or Youtube
If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.