C# Program to Find Volume and Surface Area of Cone

This is a C# Program to calculate area and volume of a cone.

Problem Description

This C# Program Calculates Area and Volume of a Cone.

Problem Solution

Here radius and height of the cone is obtained from the user and the surface area and its volume its calculated.

Program/Source Code

Here is source code of the C# Program to Calculate Area and Volume of a Cone. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

 * C# Program to Calculate Area and Volume of a Cone
using System;
using System.IO;
class program
    public static void Main()
        double r, h, surface_area, volume;
        double PI = 3.14;
        Console.WriteLine("Enter the Radius and Height of a cone : ");
        r = Convert.ToDouble(Console.ReadLine());
        h = Convert.ToDouble(Console.ReadLine());
        surface_area = PI * r * (r + Math.Sqrt(r * r + h * h));
        volume = (1.0 / 3) * PI * r * r * h;
        Console.WriteLine("Surface Area of cone is : {0} ", surface_area);
        Console.WriteLine("Volume of Cone is : {0}", volume);
Program Explanation

In this C# program, library function defined in <math.h> header file is used. We are reading the radius and height of a cone using ‘r’ and ‘h’ variable respectively. To compute the area and volume of a triangle the formula are used


Surface_area = 2 * Pi * r * (r + h),

Volume = Pi * r * r * h

Where Pi = 22/7.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
Runtime Test Cases
Enter the Radius and Height of a cone : 3 3
Surface Area of cone is : 68.2256752726637
Volume of Cone is : 28.26

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.

If you find any mistake above, kindly email to [email protected]

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.