VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-find-area-trapezoid/

⇱ Program to find area of a Trapezoid - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to find area of a Trapezoid

Last Updated : 17 Feb, 2023

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. 
 

👁 Image


In the above figure CD || AB, so they form the bases and the other two sides i.e., AD and BC form the legs. 
The area of a trapezoid can be found by using this simple formula : 
 


a = base 
b = base 
h = height 
Examples : 
 

Input : base1 = 8, base2 = 10, height = 6
Output : Area is: 54.0

Input :base1 = 4, base2 = 20, height = 7
Output :Area is: 84.0


 


 

Output : 
 

Area is: 54.0


 Time complexity: O(1)

space complexity: O(1)

Comment