# C Program to Find Area of Trapezium

This is a C Program to find area of trapezium.

Problem Description

This C Program calculates the area of trapezium.

Problem Solution

The formula used in this program are Area = (1/2) * (a + b) * h where a and b are the 2 bases of trapezium & h is the height.

Program/Source Code

Here is source code of the C Program to Find the area of a right angled triangle.The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
* C Program to Find Area of Trapezium
*/
#include <stdio.h>

int main()
{
float a, b, h;
float area;

printf("Enter the value for two bases & height of the trapezium: \n");
scanf("%f%f%f", &a, &b, &h);
area = 0.5 * (a + b) * h ;
printf("Area of the trapezium is: %.3f", area);
return 0;
}
Program Explanation

In this C program, library function defined in <math.h> header file is used to compute mathematical functions. We are reading the two bases and height of a trapezium using ‘a’, ‘b’ and ‘h’ variable. To find the surface area, the following formulas is used.

advertisement
advertisement

Area = (1/2) * (a + b) * h.

Runtime Test Cases

Output:
\$ cc pgm25.c
\$ a.out
Enter the value for two bases and height of the trapezium :
10 15 20
Area of the trapezium is: 250.000

Sanfoundry Global Education & Learning Series – 1000 C Programs.

Here’s the list of Best Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.