Q:

Program to find the surface area of the sphere

belongs to collection: Basic Programs

0

The sphere can be defined as the round 3D object having a string of points located at a uniform distance from a particular point called center. It is perfectly symmetrical and has no edges or vertices.

A sphere with radius r has a volume of (4/3) x pie x radius2 and a surface area of 4 x pie x r2.

Formula

Surface area of sphere =   4 x pie x r2

Algorithm

  1. Define the radius of the sphere.
  2. Define the value of pie.
  3. Calculate the surface area of the sphere by 4 x pie x (radius x radius).
  4. Define surface_sphere and assign the surface area of the sphere to it.

Complexity

O(1)

Input:

Radius = 37Pie = 3.14  

Output:

Volume = 4 * pie * (radius * radius);
       = 4 * 3.14 * 37 * 37
       = 17210.285714

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program

#include <stdio.h>  
int main()  
{  
   int radius=37;  
   double pie=3.14285714286;  
   double area_sphere=4*pie*(radius*radius);  
   printf("Surface area of the sphere=%f",area_sphere);  
} 

 

Output:

Surface area of the sphere=17210.285714     

 

PHP Program

<?php    
    $radius=37;  
    $pie=3.14285714286;  
    $surface_area=4*$pie*($radius*$radius);  
    echo "Surface area of sphere=";  
    echo $surface_area;  
?>  

  

Output:

Surface area of sphere=17210.285714301 

 

Java Program

public class shpere{  
      
    public static void main(String args[])  
    {  
  
    int radius=37;  
   double pie=3.14285714286;  
   double area_sphere=4*pie*(radius*radius);  
        System.out.println("Surface area of sphere="+area_sphere);  
     }  
}  

 

Output:

Surface area of sphere=17210.28571430136

 

C# Program

using System;  
                      
public class Program  
{  
    public static void Main()  
    {  
int radius=37;  
  double pie=3.14285714286;  
  double area_sphere=4*pie*(radius*radius);   
   Console.WriteLine("Surface area of sphere="+area_sphere);  
    }  
}  

 

Output:

Surface area of sphere=17210.2857143014

 

Python Program

radius=37  
pie=3.14285714286  
area_sphere=4*pie*(radius*radius)  
print("Surface area of the sphere="+str(area_sphere))  

 

Output:

Surface area of the sphere=17210.28571430136

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Program to find the volume of the cone... >>
<< Program to find the area of the square...