In this article we will show you, How to write C Program to find Area of a Trapezoid and Median of a Trapezoid with example. Before we step into practical example, Let see the definitions and formulas behind the Median and Area of a Trapezoid

## Area of a Trapezoid

If we know the height and two base lengths then we can calculate the Area of a Trapezoid using the below formula:

Area = (a+b)/2 *h

Where a and b are the two bases and h is the height of the Trapezoid

We can calculate the median of a Trapezoid using the following formula:

Median = (a+b) / 2.

If we know the Median and height then we can calculate the Area of a Trapezoid as: median*height

### C Program to find Area of a Trapezoid

This program allows the user to enter both sides of the Trapezoid and height. Using those values we will calculate the Area of a trapezoid and Median of a Trapezoid.

**CODE**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/* C Program to find Area of a Trapezoid */ #include<stdio.h> int main() { float base1, base2, height, Area, Median; printf("\n Please Enter two bases and height of the trapezium \n"); scanf("%f %f %f", &base1, &base2, &height); Area = 0.5 * (base1 + base2) * height; Median = 0.5 * (base1+ base2); printf("\n Area of a trapezium = %.2f \n", Area); printf("\n Median of a trapezium = %.2f \n", Median); return 0; } |

**OUTPUT**

**ANALYSIS**

Below printf statement will ask the user to enter base1, base and height values

1 |
printf("\n Please Enter two bases and height of the trapezium \n"); |

Below scanf statement will assign the user input values to respected variables. Such as first value will be assigned to base1, second value to base2 and third value to height

1 |
scanf("%f %f %f", &base1, &base2, &height); |

User Entered Values are base1 = 6, base2 = 9 and height = 4

Area of a Trapezoid = 0.5 * (base1 + base2) * height;

Area of a Trapezoid = 0.5 * (6 + 9) * 4;

Area of a Trapezoid = 0.5 * 15 * 4;

Area of a Trapezoid = 30

Median of a Trapezoid = 0.5 * (base1+ base2);

Median of a Trapezoid = 0.5 * (6 + 9)

Median of a Trapezoid = 0.5 * 15

Median of a Trapezoid = 7.5

Thank You for Visiting Our Blog

## Share your Feedback, or Code!!