The Wayback Machine - https://web.archive.org/web/20240928070511/https://www.geeksforgeeks.org/program-find-area-circular-segment/
Open In App

Program to find area of a Circular Segment

Last Updated : 20 Feb, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

In a circle, if a chord is drawn then that chord divides the whole circle into two parts. These two parts of the circle are called segments of the circle. The smaller area is known as the Minor segment and the larger area is called as the Major segment.
In the figure below, the chord AB divides the circle into minor and major segments. 
 

We are given radius of circle and angle that forms minor segment. We need to find areas of two segments.
Examples : 
 

Input : 
radius = 21.0
angle = 120.0
Output :
Area of minor segment 270.855
Area of major segment 1114.59

Input :
radius = 10.0
angle = 90.0
Output : 
Area of minor segment 28.5397
Area of major segment 285.619

 

 

Area of the segment :

For that, we join the end points of the chord with the center of the circle resulting in a sector which subtends some ‘angle’ at the center. And a perpendicular is drawn from the center of the circle on the chord AB. By congruence of triangles, we obtain that the ? AOP = ? BOP = 1/2(angle). 
 

Formula for Area of Segment : 
 

Area of Segment = Area of sector - Area of Triangle OAB 
                = pi * r2 * (angle/360) -
                  Area of Triangle OAB

For detailed information about formula of Area of Sector, refer https://www.geeksforgeeks.org/area-of-a-sector/. 
 

 

In the figure above, assume angle made by sector = X,
so ? AOP = ? BOP = X/2

Area of Triangle AOB = 1/2 * base * height
                     = 1/2 * AB * OP

Now in Triangle AOP, By trigonometry
Cos(X/2) = OP/AO  i.e. OP = AO * Cos(X/2) 
                       OP = r * Cos(X/2)
Sin(X/2) = AP/AO  i.e. AP = AO * Sin(X/2) 
                       AP = r * Sin(X/2)

So,
Base = AB = AP + PB
          = 2 * AP
          = 2 * r * Sin(X/2)
   
Height = OP = r * Cos(X/2)

Area of triangle = 1/2 * (2 * r * Sin(X/2)) * (r * Cos(X/2))
                    = 1/2 * r2 * Sin(X) 
                      [Using identity 2 * Sin(A) * Cos(A)]
                    = Sin(2 * A))

Hence Area of Segment =  pi * r2 * (angle/360) - 1/2 * r2 * Sin(angle)

 

C++




// C++ Program to 
// find area of 
// segment of a
// circle
#include <bits/stdc++.h>
using namespace std;
  
float pi = 3.14159;
  
// Function to find
// area of segment
float area_of_segment(float radius,
                      float angle)
{
    // Calculating area of sector
    float area_of_sector = pi *
                           (radius * radius) 
                           *(angle / 360);
  
    // Calculating area of triangle
    float area_of_triangle = (float)1 / 2 *
                             (radius * radius) *
                             sin((angle * pi) / 180);
  
    return area_of_sector - area_of_triangle;
}
  
// Driver Code
int main()
{
    float radius = 10.0, angle = 90.0;
    cout << "Area of minor segment = "
        << area_of_segment(radius, angle) << endl;
  
    cout << "Area of major segment = "
        << area_of_segment(radius, (360 - angle));
}


Java




// Java Program to find area of
// segment of a circle
class GFG {
static float pi = 3.14159f;
  
static float area_of_segment(float radius,
                              float angle)
{
    // Calculating area of sector
    float area_of_sector = pi * 
   (radius * radius) * (angle / 360);
  
    // Calculating area of triangle
    float area_of_triangle =
        (float)1 / 2 * (radius * radius) *
        (float)Math.sin((angle * pi) / 180);
  
    return area_of_sector - area_of_triangle;
}
  
// Driver Function
public static void main(String[] args) 
{
    float radius = 10.0f, angle = 90.0f;
    System.out.println("Area of minor segment = " +
                    area_of_segment(radius, angle));
  
    System.out.println("Area of major segment = " +
                    area_of_segment(radius, (360 - angle)));
}
}
  
// This code is contributed by Anant Agarwal.


Python




# Python3 Program 
# to find area of
# segment of a
# circle
import math
  
pi = 3.14159
  
# Function to find
# area of segment
def area_of_segment(radius, angle):
    # Calculating area of sector
    area_of_sector = pi * 
                     (radius * radius)
                     * (angle / 360)
  
    # Calculating area of triangle
    area_of_triangle = 1 / 2 * 
                       (radius * radius) *
                       math.sin((angle * pi) / 180)
  
    return area_of_sector - area_of_triangle;
  
  
# Driver Code
radius = 10.0
angle = 90.0
print("Area of minor segment =",
       area_of_segment(radius, angle))
print("Area of major segment =",
      area_of_segment(radius, (360 - angle)))
        
       
# This code is contributed by Smitha Dinesh Semwal


C#




// C# Program to find area 
// of segment of a circle
using System;
  
class GFG {
      static float pi = 3.14159f;
  
      static float area_of_segment(float radius,
                                   float angle)
{
    // Calculating area of sector
    float area_of_sector = pi * (radius * radius) 
                             * (angle / 360);
  
    // Calculating area of triangle
    float area_of_triangle =(float)1 / 2 * (radius * radius) 
                            *(float)Math.Sin((angle * pi) / 180);
  
    return area_of_sector - area_of_triangle;
}
  
    // Driver Function
    public static void Main() 
{
    float radius = 10.0f, angle = 90.0f;
    Console.WriteLine("Area of minor segment = " +
                        area_of_segment(radius, angle));
  
    Console.WriteLine("Area of major segment = " +
                       area_of_segment(radius, (360 - angle)));
}
}
  
// This code is contributed by vt_m.


PHP




<?php
// PHP Program to 
// find area of 
// segment of a
// circle
  
// Function to find
// area of segment
function area_of_segment($radius,
                          $angle)
                      
{
    $pi = 3.14159;
  
    // Calculating area of sector
    $area_of_sector = $pi * ($radius * $radius) * 
                                   ($angle / 360);
  
    // Calculating area of triangle
    $area_of_triangle = 1 / 2 *    ($radius * $radius) 
                              * sin(($angle * $pi) / 180);
  
    return $area_of_sector - $area_of_triangle;
}
  
    // Driver Code
    $radius = 10.0; 
    $angle = 90.0;
    echo ("Area of minor segment = ");
    echo( area_of_segment($radius, $angle));
    echo("\n");
  
    echo("Area of major segment = ");
    echo(area_of_segment($radius, (360 - $angle)));
      
// This code is contributed by vt_m.
?>


Javascript




<script>
  
// javascript program to find area of
// segment of a circle
let pi = 3.14159;
  
function area_of_segment(radius,
                              angle)
{
    // Calculating area of sector
    let area_of_sector = pi * 
   (radius * radius) * (angle / 360);
    
    // Calculating area of triangle
    let area_of_triangle =
        1 / 2 * (radius * radius) *
        Math.sin((angle * pi) / 180);
    
    return area_of_sector - area_of_triangle;
}
    
  
// Driver Function
  
         let radius = 10.0, angle = 90.0;
    document.write("Area of minor segment = " +
                    area_of_segment(radius, angle) + "<br/>");
    
    document.write("Area of major segment = " +
                    area_of_segment(radius, (360 - angle)));
      
    // This code is contributed by jana_sayantan.
</script>


Output : 
 

Area of minor segment = 28.5397
Area of major segment = 285.619

Time Complexity: O(1) 
Auxiliary Space: O(1)

Please suggest if someone has a better solution which is more efficient in terms of space and time.



Previous Article
Next Article

Similar Reads

Find middle point segment from given segment lengths
Given an array arr[] of size M. The array represents segment lengths of different sizes. These segments divide a line beginning with 0. The value of arr[0] represents a segment from 0 arr[0], value of arr[1] represents segment from arr[0] to arr[1], and so on. The task is to find the segment which contains the middle point, If the middle segment do
6 min read
Largest Rectangular Area in a Histogram using Segment Tree
Find the largest rectangular area possible in a given histogram where the largest rectangle can be made of a number of contiguous bars. For simplicity, assume that all bars have same width and the width is 1 unit. For example, consider the following histogram with 7 bars of heights {6, 2, 5, 4, 5, 1, 6}. The largest possible rectangle possible is 1
15+ min read
What is Circular Queue | Circular Queue meaning
A circular queue is an extended version of regular queue in which the last element of the queue is connected to the first element of the queue forming a cycle. Properties of Circular Queue: Along with the properties of a regular queue the circular queue has som other unique properties as mentioned below: Front and rear pointers: Two pointers, one a
4 min read
Circular Linked List Implementation of Circular Queue
Prerequisite – Circular Singly Linked List We have discussed basics and how to implement circular queue using array in set 1. Circular Queue | Set 1 (Introduction and Array Implementation) In this post another method of circular queue implementation is discussed, using Circular Singly Linked List. Operations on Circular Queue: Front:Get the front i
9 min read
Find area of the larger circle when radius of the smaller circle and difference in the area is given
Given two integers r and d where r is the radius of the smaller circle and d is the difference of the area of this circle with some larger radius circle. The task is to find the area of the larger circle.Examples: Input: r = 4, d = 5 Output: 55.24 Area of the smaller circle = 3.14 * 4 * 4 = 50.24 55.24 - 50.24 = 5Input: r = 12, d = 3 Output: 455.16
4 min read
Find area of the Circle when the area of inscribed Square is given
Given the area of a square inscribed in a circle as N, the task is to calculate the area of a circle in which the square is inscribed. Examples: Input: N = 4 Output: 6.283 Input: N = 10Output: 15.707 Approach: Consider the below image: Let the area of the square is 'A'The side of the square is given by = A**(1/2)A right-angled triangle is formed by
4 min read
Class 8 RD Sharma Solutions- Chapter 22 Mensuration III (Surface Area And Volume Of Right Circular Cylinder) - Exercise 22.2 | Set 1
Question 1. Find the volume of a cylinder whose (i) r = 3.5 cm, h = 40 cm (ii) r = 2.8 m, h = 15 m Solution: (i) Given that, r = 3.5 cm, h = 40 cm As we know that Volume of a cylinder = πr2h = 22/7 × 3.5 × 3.5 × 40 = 1540 cm3 (ii) Given that, r = 2.8 m, h =15 m As we know that Volume of a cylinder = πr2h = 22/7 × 2.8 × 2.8 × 15 = 369.6 m3 Question
11 min read
Class 9 RD Sharma Solutions - Chapter 19 Surface Area And Volume of a Right Circular Cylinder - Exercise 19.2 | Set 2
Question 17. The height of a right circular cylinder is 10.5 m. Three times the sum of the areas of its two circular faces is twice the area of the curved surface. Find the volume of the cylinder. Solution: Given that Height of the cylinder = 10.5 m According to the question 3(2πr2) = 2(2πrh) 3r = 2h r = 2/3 x h r = 2/3 x 10.5 = 7cm So, the radius
14 min read
Area of a Circular Sector
A circular sector or circle sector is the portion of a disk enclosed by two radii and an arc, where the smaller area is known as the minor sector and the larger being the major sector. Let's look at this figure and try to figure out the sector: In this figure the green shaded part is a sector, "r" is the Radius and "theta" is the angle as shown. He
4 min read
Class 9 RD Sharma Solutions - Chapter 19 Surface Area And Volume of a Right Circular Cylinder - Exercise 19.2 | Set 1
This geometric figure is known as Right Circular Cylinder, which has ample usages in day to day real life situation arises in Engineering, Architecture and Manufacture. It is well used in areas of estimations concerning materials as well as design works concerning the physical structure of an object. Area of regression: right circular cylinderThis
14 min read
Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
Given radius and height of Cylinder, calculate the volume, total surface area and curved surface area of cylinder. Volume of Cylinder: The volume of cylinder is defined as the amount of three dimensional space occupied by the cylinder or the storage capacity of a cylinder. We can calculate volume of cylinder by using formula: where ' r 'is radius o
7 min read
Radius of a circle having area equal to the sum of area of the circles having given radii
Given two integers r1 and r2, representing the radius of two circles, the task is to find the radius of the circle having area equal to the sum of the area of the two circles having given radii. Examples: Input:r1 = 8r2 = 6Output:10Explanation:Area of circle with radius 8 = 201.061929 Area of a circle with radius 6 = 113.097335Area of a circle with
5 min read
Check if an area P can be obtained from an area of N * M
Given integers N, M and P, the task is to check if is possible to find a rectangular area of P sq. units inside a rectangular area of N × M sq units. Examples: Input: N = 3, M = 3, P = 4Output: YESExplanation: Rectangle of 2 x 2 sq. unit area Input: N = 4, M = 4, P = 7Output: NO Approach: Follow the steps below to solve the problem Find all the fac
6 min read
Javascript Program to Find array sum using Bitwise OR after splitting given array in two halves after K circular shifts
Given an array A[] of length N, where N is an even number, the task is to answer Q independent queries where each query consists of a positive integer K representing the number of circular shifts performed on the array and find the sum of elements by performing Bitwise OR operation on the divided array.Note: Each query begins with the original arra
5 min read
Find the segment that overlaps with maximum number of segments
Given a 2D array segments[][] where each segment is of the form [L, R] representing (X, Y) co-ordinates, the task is to find a segment that overlaps with maximum number of segments. Examples: Input: segments[][] = {{1, 4}, {2, 3}, {3, 6}}Output: {3, 6}Explanation: Every segment overlaps with all other segments. Therefore, print any one of them. Inp
9 min read
Find element using minimum segments in Seven Segment Display
A Seven Segment Display can be used to display numbers. Given an array of n natural numbers. The task is to find the number in the array which is using minimum segments to display number. If multiple numbers have a minimum number of segments, output the number having the smallest index. Examples : Input : arr[] = { 1, 2, 3, 4, 5 }. Output : 1 1 use
7 min read
Find an Integer point on a line segment with given two ends
Given two points pointU and pointV in XY-space, we need to find a point which has integer coordinates and lies on a line going through points pointU and pointV. Examples: If pointU = (1, -1 and pointV = (-4, 1) then equation of line which goes through these two points is, 2X + 5Y = -3 One point with integer co-ordinate which satisfies above equatio
8 min read
Program to find area of a Trapezoid
Definition of Trapezoid : A Trapezoid is a convex quadrilateral with at least one pair of parallel sides. The parallel sides are called the bases of the trapezoid and the other two sides which are not parallel are referred to as the legs. There can also be two pairs of bases. In the above figure CD || AB, so they form the bases and the other two si
4 min read
Program to find the Area of an Ellipse
Given an ellipse with a semi-major axis of length a and semi-minor axis of length b. The task is to find the area of an ellipse.In mathematics, an ellipse is a curve in a plane surrounding by two focal points such that the sum of the distances to the two focal points is constant for every point on the curve or we can say that it is a generalization
4 min read
Program to find the Area and Volume of Icosahedron
Given the side of an Icosahedron. The task is to find the area and volume of the given Icosahedron.Examples : Input : a = 5 Output : Area: 216.506 Volume: 272.712 Input : a = 10 Output : Area: 866.0254 Volume: 2181.695 In geometry, an Icosahedron is a regular polyhedron which contains 20 identical equilateral triangular faces, 30 sides, and 12 vert
5 min read
Program to find the surface area of the square pyramid
Given the base length(b) and slant height(s) of the square pyramid. The task is to find the surface area of the Square Pyramid. A Pyramid with a square base, 4 triangular faces, and an apex is a square pyramid. In this figure, b – base length of the square pyramid. s – slant height of the square pyramid. h – height of the square pyramid.Examples: I
3 min read
Program to find volume and surface area of pentagonal prism
A prism that has 5 rectangular faces and 2 parallel pentagonal bases is a pentagonal prism. So you are given the apothem length(a), base length(b) and height(h) of the pentagonal prism. you have to find the surface area and the volume of the Pentagonal Prism.Examples: Input : a=3, b=5, h=6 Output :surface area=225, volume=225 Input : a=2, b=3, h=5
4 min read
Program to find the Area of a Parallelogram
Given the sides of a Parallelogram, task is calculate the area of a Parallelogram. Examples: Input: base = 30, height = 40 Output: 1200.000000 As Area of parallelogram = base * height, Therefore, Area = 30 * 40 = 1200.00 Approach: Area of parallelogram = base * height Below is the implementation of the above approach: C/C++ Code #include <iostre
2 min read
Program to find the Area and Perimeter of a Semicircle
Given the radius of the semicircle as r, the task is to find out the Area and Perimeter of that semicircle.Examples: Input: r = 10 Output: Area = 157.00, Perimeter = 31.4 Input: r = 25 Output: Area =981.250000, Perimeter = 78.500000 Approach: In mathematics, a semicircle is a one-dimensional locus of points that forms half of a circle. The area of
5 min read
Program to find Area of Triangle inscribed in N-sided Regular Polygon
Given the triangle inscribed in an N-sided regular polygon with given side length, formed using any 3 vertices of the polygon, the task is to find the area of this triangle. Examples: Input: N = 6, side = 10 Output: 129.904 Input: N = 8, side = 5 Output: 45.2665 Approach: Consider the 1st example: Given is a 6 sided regular polygon ABCDEF with a tr
6 min read
Program to find Surface Area and Volume of Octagonal Prism
Given the base length, height, and distance of Octagonal Prism we have to find the Surface Area and Volume of the octagonal prism for the given parameters. The octagonal prism is a solid three-dimensional object having a total of 10 faces, 24 edges, and 16 vertices. The two faces at either end are octagons and the rest of the faces are rectangular.
5 min read
Program to find all possible triangles having same Area and Perimeter
The task is to find all possible triangles having the same perimeter and area. Examples: The triangle having sides (6, 8, 10) have the same perimeter (= (6 + 8 + 10) = 24) and area (= 0.5 * 6 * 8 = 24). Approach: The idea is based on the observation from Heron's Formula. Below are the observations: Let the sides of the triangle be a, b, c.Perimeter
9 min read
JavaScript program to find Area and Perimeter of Rectangle
A rectangle is a flat figure in a plane. It has four sides and four equal angles of 90 degrees each. In a rectangle all four sides are not of equal length like a square, sides opposite to each other have equal length. Both diagonals of the rectangle have equal lengths. Examples: Input: 4 5 Output: Area = 20 Perimeter = 18 Input: 2 3 Output: Area =
1 min read
Program to find area of a triangle
Given the sides of a triangle, the task is to find the area of this triangle. Examples : Input : a = 5, b = 7, c = 8 Output : Area of a triangle is 17.320508 Input : a = 3, b = 4, c = 5 Output : Area of a triangle is 6.000000Recommended PracticeArea of a triangleTry It! Approach: The area of a triangle can simply be evaluated using following formul
10 min read
Program to find the area of a Square
What is a square ? Square is a flat shape, in one plane, defined by four points at the four corners. A square has four sides all of equal length, and four corners, all right angles (90 degree angles). A square is a kind of rectangle but with all sides equal. Formula : [Tex]Area = side * side [/Tex]Examples: Input : 4 Output :16 Input :8 Output :64
3 min read