Given slant height, height and radius of a cone, we have to calculate the volume and surface area of the cone.
Cone is a three dimensional geometric shape. It consists of a base having the shape of a circle and a curved side (the lateral surface) ending up in a tip called the apex or vertex.

The volume of a cone is given by the formula –
volume = 1/3(pi * r * r * h)
where r is the radius of the circular base, and h is the height (the perpendicular distance from the base to the vertex).
The surface area of a cone is given by the formula –
area = pi * r * s + pi * r^2
Where r is the radius of the circular base, and s is the slant height of the cone.
Examples :
Input : radius = 5 slant_height = 13 height = 12 Output : Volume Of Cone = 314.159 Surface Area Of Cone = 282.743 Input : radius = 6 slant_height = 10 height = 8 Output : Volume Of Cone = 301.593 Surface Area Of Cone = 301.593
C++
// CPP program to calculate Volume // and Surface area of Cone #include<iostream> using namespace std; float pi = 3.14159; // Function to calculate // Volume of cone float volume(float r, float h) { return (float(1) / float(3)) * pi * r * r * h; } // Function to calculate // Surface area of cone float surface_area(float r, float s) { return pi * r * s + pi * r * r; } // Driver Code int main() { float radius = 5; float slant_height = 13; float height = 12; float vol, sur_area; // Printing value of volume // and surface area cout << "Volume Of Cone : " << volume(radius, height) << endl; cout << "Surface Area Of Cone : " << surface_area(radius, slant_height); return 0; } |
Java
// Java program to calculate // Volume and Surface area of cone class GFG { static float pi = 3.14159f; // Function to calculate // Volume of cone public static float volume(float r, float h) { return (float)1 / 3 * pi * h * r * r; } // Function to calculate // Surface area of cone public static float surface_area(float r, float s) { return pi * r * s + pi * r * r; } // Driver Code public static void main(String args[]) { float radius = 5; float slant_height = 13; float height = 12; float vol, sur_area; // Printing value of volume // and surface area System.out.print("Volume Of Cone : "); System.out.println(volume(radius, height)); System.out.print("Surface Area Of Cone : "); System.out.println(surface_area(radius, slant_height)); } } // This code is contributed by "akanshgupta" |
Python
''' Python3 program to calculate Volume and Surface area of Cone''' # Importing Math library for value Of PI import math pi = math.pi # Function to calculate Volume of Cone def volume(r, h): return (1 / 3) * pi * r * r * h # Function To Calculate Surface Area of Cone def surfacearea(r, s): return pi * r * s + pi * r * r # Driver Code radius = float(5) height = float(12) slat_height = float(13) print( "Volume Of Cone : ", volume(radius, height) ) print( "Surface Area Of Cone : ", surfacearea(radius, slat_height) ) |
C#
// C# program to calculate // Volume and Surface area of cone using System; class GFG { static float pi = 3.14159f; // Function to calculate // Volume of cone public static float volume(float r, float h) { return (float)1 / 3 * pi * h * r * r; } // Function to calculate // Surface area of cone public static float surface_area(float r, float s) { return pi * r * s + pi * r * r; } // Driver Code public static void Main() { float radius = 5; float slant_height = 13; float height = 12; //float vol, sur_area; // Printing value of volume // and surface area Console.Write("Volume Of Cone : "); Console.WriteLine(volume(radius, height)); Console.Write("Surface Area Of Cone : "); Console.WriteLine(surface_area(radius, slant_height)); } } // This code is contributed by "vt_m" |
PHP
<?php // PHP program to calculate Volume // and Surface area of Cone // Function to calculate Volume of cone function volume( $r, $h) { $pi = 3.14159; return (1 / 3) * $pi * $r * $r * $h; } // Function to calculate // Surface area of cone function surface_area($r, $s) { $pi = 3.14159; return $pi * $r * $s + $pi * $r * $r; } // Driver Code $radius = 5; $slant_height = 13; $height = 12; //vol, sur_area; // Printing value of volume // and surface area echo("Volume Of Cone : "); echo( volume($radius, $height)); echo("\n"); echo("Surface Area Of Cone : "); echo( surface_area($radius, $slant_height)); // This code is contributed by vt_m. ?> |
Output :
Volume Of Cone : 314.159 Surface Area Of Cone : 282.743
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Program for Volume and Surface area of Frustum of Cone
- Calculate Volume and Surface area Of Sphere
- Program to calculate Volume and Surface area of Hemisphere
- Calculate volume and surface area of Torus
- Program for Volume and Surface Area of Cube
- Program for Volume and Surface Area of Cuboid
- Surface Area and Volume of Hexagonal Prism
- Program to find volume and surface area of pentagonal prism
- Program to find Surface Area and Volume of Octagonal Prism
- Minimum volume of cone that can be circumscribed about a sphere of radius R
- Program to calculate the Surface Area of a Triangular Prism
- Program to calculate area and volume of a Tetrahedron
- Find the Surface area of a 3D figure
- Program for Surface Area of Octahedron
- Program for Surface area of Dodecahedron
- Program to find the surface area of the square pyramid
- Program to calculate volume of Ellipsoid
- Program to calculate volume of Octahedron
- Calculate Volume of Dodecahedron
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : vt_m

