In this video, we will write a C program to find the area and perimeter of a semicircle. Semicircle is a one-dimensional locus of points that forms half of a circle. The area of a semicircle is half the area of the circle from which it is made. Any diameter of a circle cuts it into two equal semicircles.
Formula:
Area of Semi-Circle = 1⁄2 * π *r2
The perimeter of Semi-Circle = π *r
where “r” is the radius of the semicircle.
Examples:
Semicircle Area and Perimeter:
A = πr²/2 = 12.5 * π [cm²]
≈ 39.27 [cm²]
Perimeter (L) = πr + d = 5 * π + 10 [cm]
≈ 25.708 [cm]
Calculate Area & Perimeter of Semicircle - 2 Approaches
1) Using formula:
Step 1: Take input R from the user.
Step 2: Calculate the area and perimeter using a simple formula of the semicircle.
Step 3: Print the result.
2) Using function:
Step 1: Create user define function.
Step 2: Calculate area and perimeter using function.
Step 3: Print the result.
The Time and Space complexity of both the approaches are O(1).