VOOZH about

URL: https://www.geeksforgeeks.org/dsa/area-of-incircle-of-a-right-angled-triangle/

⇱ Area of Incircle of a Right Angled Triangle - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Area of Incircle of a Right Angled Triangle

Last Updated : 6 Jul, 2022

Given the P, B and H are the perpendicular, base and hypotenuse respectively of a right angled triangle. The task is to find the area of the incircle of radius r as shown below:
 

👁 Image


Examples: 
 

Input: P = 3, B = 4, H = 5 
Output: 3.14
Input: P = 5, B = 12, H = 13 
Output: 12.56 
 


 


Approach: Formula for calculating the inradius of a right angled triangle can be given as r = ( P + B - H ) / 2
And we know that the area of a circle is PI * r2 where PI = 22 / 7 and r is the radius of the circle. 
Hence the area of the incircle will be PI * ((P + B - H) / 2)2.
Below is the implementation of the above approach:
 


Output: 
3.141593

 

Time Complexity : O(1)

Auxiliary Space: O(1)

Comment
Article Tags: