logo image

C Language program to calculate trapezoid area

Views: 17

Following program shows you how to calculate trapezoid area. This program gets trapezoid base and height from user and calculates area and prints it using following formula Area = (base1 + base2) X height /2

#include <stdio.h>

int main(void) {
	float trapezoidBase1;
	float trapezoidBase2;
	float trapezoidHeight;

	printf("Please enter base1 of trapezoid:");
	scanf("%f", &trapezoidBase1);

	printf("Please enter base2 of trapezoid:");
	scanf("%f", &trapezoidBase2);

	printf("Please enter height of trapezoid:");
	scanf("%f", &trapezoidHeight);

	float areaOfTrapezoid =
		(trapezoidBase1 + trapezoidBase2) * trapezoidHeight / 2;

	printf("Area of trapezoid is: %f", areaOfTrapezoid);


Please enter base1 of trapezoid: 13
Please enter base2 of trapezoid: 15
Please enter height of trapezoid: 20
Area of trapezoid is: 280.000000 
We are looking for Interns!
Send your resumes to
[email protected]