Practical Number :
04 Roll No :
1615
Que 4) Write a console program to calculate area of sphere by using
function. using System.
using [Link];
using [Link];
using [Link];
using [Link];
namespace Journal
{
class practical
{
//Function to calculate the area of a sphere
static double SphereArea(double radius)
{
return 4 * 3.1416 * radius * radius;
}
static void Main()
{
[Link]("Enter the radius of the sphere:");
double radius = [Link]([Link]());
double area = SphereArea(radius);
[Link]("Surface area of the sphere is:" + area);
[Link]();
}
}
}
Output of the Code: