Program to calculate Volume and Surface area of Hemisphere


Calculate volume and surface area of a hemisphere.
Hemisphere :
In geometry, it is an exact half of a sphere. We can find many of the real life examples of the hemispheres such as our planet Earth can be divided into two hemisphere the southern & northern hemispheres.
4
Volume of Hemisphere : Volume of a Hemisphere is nothing but the amount of space occupied by the hemisphere. It is also defined as the quantity of three dimensional space enclosed by the boundary of the Hemisphere.

Surface area : The number of square units that will exactly cover the surface of a hemisphere.
surface area = 2 \pi r^2
volume = \frac{2 \pi r^2}{3}

Examples :

Input :  Radius = 7
Output : Volume = 718.378
         Surface Area = 307.876

Input :  Radius = 11
Output : Volume = 2787.64
         Surface Area = 760.265

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

// CPP Program to calulate volume and
// and surface area of a Hemisphere.
#include <bits/stdc++.h>
using namespace std;
// Initializing value of pi
#define pi 3.141592653589793
  
// Function to calulate volume
void volume(float r)
{
    float volume = float(2 * pi * pow(r, 3)) / float(3);
    cout << "Volume = " << volume << endl;
}
// Function to calulate surface area
void surface_area(float r)
{
    float s_area = 2 * pi * pow(r, 2);
    cout << "Surface Area = " << s_area << endl;
}
  
// Driver program
int main()
{
    float r = 11;
    volume(r);
    surface_area(r);
    return 0;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Program to calulate volume and
// and surface area of a Hemisphere.
import java.util.*;
import java.lang.*;
  
public class GfG{
      
    // Initializing value of pi
    private static final float pi = (float) 3.141592653589793;
  
    // Function to calulate volume
    public static void volume(float r)
    {
        float volume = (float)(2 * pi *(float) Math.pow(r, 3)) 
                                                    / (float)(3);
        System.out.println("Volume = " + volume);
    }
    // Function to calulate surface area
    public static void surface_area(float r)
    {
        float s_area = (float)2 * pi * (float)Math.pow(r, 2);
        System.out.println("Surface Area = " + s_area);
    }
      
    // Driver function
    public static void main(String argc[]){
        float r = 11;
        volume(r);
        surface_area(r);
    }
      
}
/* This code is contributed by Sagar Shukla */

chevron_right


Python

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python code Program to calculate volume and
# and surface area of a Hemisphere.
import math
  
# Function to calculate volume
def volume(r):
    volume = 2 * math.pi * math.pow(r, 3) / 3
    print("Volume = ", '%.4f' %volume)
  
# Function to calculate surface area
def surface_area(r):
    s_area = 2 * math.pi * math.pow(r, 2)
    print("Surface Area = ", '%.4f' %s_area)
      
# Driver code
r = 11
volume(r)
surface_area(r)

chevron_right


C#

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# Program to calulate volume and
// and surface area of a Hemisphere.
using System;
  
public class GfG{
      
    // Initializing value of pi
    private static float pi = (float) 3.141592653589793;
  
    // Function to calulate volume
    public static void volume(float r)
    {
        float volume = (float)(2 * pi *(float) Math.Pow(r, 3)) 
                                                / (float)(3);
        Console.WriteLine("Volume = " + volume);
    }
      
    // Function to calulate surface area
    public static void surface_area(float r)
    {
        float s_area = (float)2 * pi * (float)Math.Pow(r, 2);
        Console.WriteLine("Surface Area = " + s_area);
    }
      
    // Driver function
    public static void Main()
    {
        float r = 11;
        volume(r);
        surface_area(r);
    }
      
}
  
/* This code is contributed by vt_m */

chevron_right


PHP

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP Program to calulate volume and
// and surface area of a Hemisphere.
  
// Initializing value of pi &
// Function to calulate volume
function volume($r)
{
    $pi =3.141592653589793;
    $volume = (2 * $pi
               pow($r, 3)) /(3);
    echo("Volume = " );
    echo($volume);
    echo("\n");
}
  
// Function to calulate 
// surface area
function surface_area($r)
{
    $pi = 3.141592653589793;
    $s_area = 2 * $pi * pow($r, 2);
    echo( "Surface Area = ");
    echo($s_area) ;
}
  
// Driver code
$r = 11;
volume($r);
surface_area($r);
  
// This code is contributed by vt_m 
?>

chevron_right



Output :

Volume = 2787.64
Surface Area = 760.265


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : vt_m