Q:

Write a Program to calculate the Surface Area of Hemisphere

belongs to collection: Miscellaneous Programs Examples

0

Before writing the program of calculating the surface area of hemisphere in different programming languages, firstly we have to know about what is hemisphere and what is the formula of the surface area?

What is Hemisphere?

A hemisphere is a half-part of the sphere.

Surface Area of Hemisphere is the total number of square units which exactly cover the hemisphere surface.

 

Surface Area of Hemisphere = 2 * pie * r2  

Where, r is the radius of hemisphere  

All Answers

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

Program of calculating the surface area of a hemisphere in different Programming languages

Program 1: Write a Program in C language:

// This is a C program which uses a function to calculate the surface area of a hemisphere.  
#include <stdio.h>  
  
float find_SurfaceArea_of_hemisphere(float r) // It is a function to find surface area   
{   
    float pi=3.14;  
    float SurfaceArea_of_hemisphere;  
    SurfaceArea_of_hemisphere=( 2 * pi * r * r ) ; // It is a formula for calculating a surface area of hemisphere   
    return (SurfaceArea_of_hemisphere);   
}   
float main()   
{   
float r;   
printf("Enter the radius of the hemisphere:");   
scanf("%f",&r);  
printf("Surface Area of the hemisphere is: %f", find_SurfaceArea_of_hemisphere(r));     
return 0;   
}  

 

Output of Above C program:

Enter the radius of the hemisphere:10
Surface Area of the hemisphere is: 628.000000

 

Program 2: Write a Program in Java language:

// This a  Java program which calculates the surface area of a hemisphere.  
import java.util.*;  
import java.lang.*;  
class findsurface_area {   
static double find_SurfaceArea_of_hemisphere(float r)   
{   
double SurfaceArea_of_hemisphere;  
SurfaceArea_of_hemisphere= ( 2 * 3.14 * Math.pow ( r, 2 ) ); // It is a formula for calculating the surface area of hemisphere   
return(SurfaceArea_of_hemisphere);   
}   
  
// Driver method   
public static void main(String[] args)   
{   
float radius = 10;   
System.out.println("The Surface Area of a hemisphere in Java:");  
System.out.println(find_SurfaceArea_of_hemisphere(radius));   
}   
}  

 

Output of Above Java program:

The Surface Area of a hemisphere in Java:
628.0

 

Program 3: Write a Program in PHP programming language.

<?php   
// This a  PHP program which calculates the surface area of a hemisphere.    
// Function to find surface area   
function find_SurfaceArea_of_hemisphere($r)   
{     
$pi =  3.141592653589793;  
$SurfaceArea_of_hemisphere = ( 2 * 3.14 * $r * $r ); // It is a formula which calculates the surface area  and store the value in the Surface Area_of_hemisphere variable.   
return ($SurfaceArea_of_hemisphere);   
}   
$radius = 10;   
echo find_SurfaceArea_of_hemisphere($radius);   
  
?>  

 

Output of Above PHP program:

628

 

Program 4: Write a Program in Python programming language.

# This is a python program which calculates the surface area of a hemisphere.   
# It is a function to calculate the surface area of hemisphere  
def find_SurfaceArea_of_hemisphere(radius):  
    return ( ( 2 * 3.14 * ( radius * radius ) ) ) # It is a formula which calculates the value of Surface Area.   
  
radius =10  
print(find_SurfaceArea_of_hemisphere(radius))  

 

Output of Above Python program:

628.0

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

total answers (1)

Miscellaneous Programs Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Program to find the Perimeter of Ellipse... >>
<< Write a Program to calculate the surface Area of C...