C# Sharp Programming Exercises

C# Sharp Exercises: Calculate and display the surface and volume of a sphere

C# Sharp Basic Data Types: Exercise-8 with Solution

Write a C# Sharp program that takes the radius of a sphere as input and calculate and display the surface and volume of the sphere.

C# Sharp: Area and volume of a sphere

A sphere is a perfectly round geometrical object in three-dimensional space that is the surface of a completely round ball.

In three dimensions, the volume inside a sphere is derived to be V = 4/3*π*r3 where r is the radius of the sphere

C# Sharp: Volume of a sphere

The area of a sphere is A = 4*π*r2

C# Sharp: Area of a sphere

Sample Solution:-

C# Sharp Code:

using System;
public class Exercise8
    public static void Main()
        float r;
        float pi = 3.1415926535f;
        Console.Write("Radius: ");
        r = Convert.ToSingle(Console.ReadLine());
        Console.WriteLine( 4 * pi * (r * r) );
        Console.WriteLine( 4f/3f * pi * (r * r * r));

Sample Output:

Radius: 2                                                                                                     


Flowchart: Calculate the speed in kilometers and miles per hour from distance and time.

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a C# Sharp program that takes distance and time as input and displays the speed in kilometers per hour and miles per hour.
Next: Write a C# Sharp program that takes a character as input and check the input (lowercase) is a vowel, a digit, or any other symbol.

What is the difficulty level of this exercise?

New Content: Composer: Dependency manager for PHP, R Programming