Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder - GeeksforGeeks

17 Mar, 2021
Given radius and height of Cylinder, calculate the volume, total surface area and curved surface area of cylinder. 
Volume of Cylinder: The volume of cylinder is defined as the amount of three dimensional space occupied by the cylinder or the storage capacity of a cylinder. We can calculate volume of cylinder by using formula: 
where ‘ r ‘is radius of the base and ‘ h ‘ is height of cylinder.
 
Total Surface Area of Cylinder: Surface area of cylinder is the number of square units that will exactly cover outer surface of a cone. There are three surfaces in a cylinder, one curved and two circular bases. Total surface area of cylinder is the sum of the area of both circular bases and area of curved surface. The total surface area includes the area of the circular top and base, as well as the Curved Surface Area (CSA).We can calculate curved surface area and total surface area by using formula:
 
Examples:  
Input  : Enter Radius Of Cylinder   5
         Enter Height Of Cylinder   8
Output : Volume       Of       Cylinder   =   628.3185307179587
         Total  Surface Area  Of Cylinder =   408.4070449666731
         Curved Surface Area  Of Cylinder =   251.32741228718345


Input  :Enter Radius Of Cylinder   15
        Enter Height Of Cylinder   10
Output :Volume       Of       Cylinder      =   7068.583470577034
        Total  Surface Area  Of Cylinder =   2356.194490192345
        Curved Surface Area  Of Cylinder =   942.4777960769379
 
 
C
C++
Java
Python
C#
PHP
Javascript
#include <stdio.h>#define PI 3.14159 // Function To Calculate Volume OF Cylinderfloat volume(float r, float h){    float vol = PI * r * r * h;    printf("Volume of Cylinder = %f \n" ,  vol);} // Function To Calculate Total Surface Area OF Cylinderfloat totalsurfacearea(float r, float h){    float tsurf_ar = (2 * PI * r * h) + (2 * PI * r * r);    printf("Total Surface Area Of Cylinder = %f \n" ,  tsurf_ar);} // Function To Calculate Curved Surface Area OF Cylinderfloat curvedsurfacearea(float r, float h){    float cursurf_ar = (2 * PI * r * h);    printf("Curved Surface Area Of Cylinder = %f \n" ,  cursurf_ar);} // Driver Codeint main(){    float r = 5;    float h = 8;     // Function Call And Printing Volume, TSA, CSA Of Cylinder    volume(r, h);    totalsurfacearea(r, h);    curvedsurfacearea(r, h);    return 0;}// This code is contributed by Abhishek Agrawal.
#include <bits/stdc++.h>#define PI 3.14159using namespace std; // Function To Calculate Volume OF Cylindervoid volume(float r, float h){    float vol = PI * r * r * h;    cout  << "Volume of Cylinder =    " << vol << "\n" ;} // Function To Calculate Total Surface Area OF Cylindervoid totalsurfacearea(float r, float h){    float tsurf_ar = (2 * PI * r * h) + (2 * PI * r * r);    cout << "Total Surface Area Of Cylinder = " << tsurf_ar << "\n";} // Function To Calculate Curved Surface Area OF Cylindervoid curvedsurfacearea(float r, float h){    float cursurf_ar = (2 * PI * r * h);    cout << "Curved Surface Area Of Cylinder = "           << cursurf_ar << "\n";} // Driver codeint main(){    float r = 5;    float h = 8;    volume(r, h);    totalsurfacearea(r, h);    curvedsurfacearea(r, h);}// This code is contributed by Abhishek Agrawal.
// java code for illustion....import java.io.*; class GFG{    static double PI = 3.14159;         // Function To Calculate Volume OF Cylinder    static void volume(double r, double h)    {        double vol = PI * r * r * h;            System.out.println( "Volume of Cylinder = "                                + vol );    }         // Function To Calculate Total Surface Area OF Cylinder    static void totalsurfacearea(double r, double h)    {        double tsurf_ar = (2 * PI * r * h) + (2 * PI * r * r);        System.out.println( "Total Surface Area Of Cylinder = "                            + tsurf_ar );    }         // Function To Calculate Curved Surface Area OF Cylinder    static void curvedsurfacearea(double r, double h)    {        double cursurf_ar = (2 * PI * r * h);        System.out.println( "Curved Surface Area Of Cylinder = "                            + cursurf_ar );    }     // Driver code    public static void main (String[] args)    {        double r = 7;        double h = 6;        volume(r, h);        totalsurfacearea(r, h);        curvedsurfacearea(r, h);    }} // This code is contributed by Sunnysingh
# Importing Math Library For The Value Of PIimport mathpi = math.pi # Function To Calculate Volume OF Cylinderdef volume(r, h):    vol = pi * r * r * h    return vol # Function To Calculate Total Surface Area# of Cylinderdef totalsurfacearea(r, h):    tsurf_ar = (2 * pi * r * h) + (2 * pi * r * r)    return tsurf_ar # Function To Calculate Curved Surface Area# of Cylinderdef curvedsurfacearea(r, h):    cursurf_ar = (2 * pi * r * h)    return cursurf_ar # Driver Coder = 5h = 8# Function Call And Printing Volume, TSA, CSA Of Cylinderprint("Volume       Of       Cylinder   =  ",volume(r, h))print("Total  Surface Area  Of Cylinder =  ",totalsurfacearea(r,h))print("Curved Surface Area  Of Cylinder =  ",curvedsurfacearea(r,h))
// C# code for illustion....using System; class GFG {         static double PI = 3.14159;         // Function To Calculate Volume OF Cylinder    static void volume(double r, double h)    {        double vol = PI * r * r * h;            Console.WriteLine( "Volume of Cylinder = "                                + vol );    }         // Function To Calculate Total Surface Area    // OF Cylinder    static void totalsurfacearea(double r, double h)    {        double tsurf_ar = (2 * PI * r * h) +                                    (2 * PI * r * r);        Console.WriteLine( "Total Surface Area Of "                        + "Cylinder = " + tsurf_ar );    }         // Function To Calculate Curved Surface Area    // OF Cylinder    static void curvedsurfacearea(double r, double h)    {        double cursurf_ar = (2 * PI * r * h);        Console.WriteLine( "Curved Surface Area Of"                  + " Cylinder = " + cursurf_ar );    }     // Driver code    public static void Main ()    {        double r = 5;        double h = 8;                 volume(r, h);        totalsurfacearea(r, h);        curvedsurfacearea(r, h);    }} // This code is contributed by vt_m.
<?php     // Function To Calculate Volume OF Cylinderfunction volume( $r, $h){    $PI = 3.14159;    $vol = $PI * $r * $r * $h;    echo("Volume of Cylinder =");    echo($vol);    echo("\n");} // Function To Calculate Total Surface// Area OF Cylinderfunction totalsurfacearea( $r, $h){    $PI = 3.14159;    $tsurf_ar = (2 * $PI * $r * $h)                + (2 * $PI * $r * $r);    echo("Total Surface Area Of Cylinder = ");    echo($tsurf_ar);    echo("\n");} // Function To Calculate Curved Surface// Area OF Cylinderfunction curvedsurfacearea($r, $h){    $PI =3.14159;    $cursurf_ar = (2 * $PI * $r * $h);    echo("Curved Surface Area Of Cylinder = ");    echo($cursurf_ar);} // Driver Code$r = 5;$h = 8; // Function Call And Printing Volume,// TSA, CSA Of Cylindervolume($r, $h);totalsurfacearea($r, $h);curvedsurfacearea($r, $h); // This code is contributed by vt_m.?>
<script>let PI =  3.141592653589793238; // Function To Calculate Volume OF Cylinderfunction volume( r,  h){    let vol = PI * r * r * h;    document.write("Volume of Cylinder = " + vol + "<br/>");} // Function To Calculate Total Surface Area OF Cylinderfunction totalsurfacearea( r,  h){    let tsurf_ar = (2 * PI * r * h) + (2 * PI * r * r);    document.write("Total Surface Area Of Cylinder = " +  tsurf_ar+  "<br/>");} // Function To Calculate Curved Surface Area OF Cylinderfunction curvedsurfacearea( r,  h){    let cursurf_ar = (2 * PI * r * h);    document.write("Curved Surface Area Of Cylinder = " +  cursurf_ar+ "<br/>");} // Driver Code    let r = 5;    let h = 8;     // Function Call And Printing Volume, TSA, CSA Of Cylinder    volume(r, h);    totalsurfacearea(r, h);    curvedsurfacearea(r, h);     // This code is contributed by Rajput-Ji</script>
Output:  
Volume     Of     Cylinder =  628.3185307179587
Total Surface Area Of Cylinder =  408.4070449666731
Total Surface Area Of Cylinder =  251.32741228718345
 
vt_m
gowtham_yuvaraj
Rajput-Ji
area-volume-programs
Mathematical
School Programming
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Algorithm to solve Rubik's Cube
Modular multiplicative inverse
Program to multiply two matrices
Program to print prime numbers from 1 to N.
Count ways to reach the n'th stair
Python Dictionary
Arrays in C/C++
Inheritance in C++
Reverse a string in Java
Interfaces in Java