![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find Volume and Surface Area of a Sphere using C#?
For volume and surface area of a sphere, firstly declare a variable with the value of radius.
int r = 15;
Get the volume f the sphere.
// calculating volume of sphere cal_volume = (4.0 / 3) * (22 / 7) * r * r * r;
Now the surface area of the sphere is calculated −
cal_area = 4 * (22 / 7) * r * r;
Let us see the complete code −
Example
using System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { double cal_area, cal_volume, r; // radius r = 15; // calculating area of sphere cal_area = 4 * (22 / 7) * r * r; // calculating volume of sphere cal_volume = (4.0 / 3) * (22 / 7) * r * r * r; Console.WriteLine("Area of Sphere: " + cal_area); Console.WriteLine("Volume of Sphere: " + cal_volume); } }
Output
Area of Sphere: 2700 Volume of Sphere: 13500
Advertisements