TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

program to find the surface area of sphere

program to find the surface area of sphere on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph etc.

<< Back to PROGRAM

Program to find the surface area of the sphere

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)


Solution

C Program

#include 
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    

Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf