In this post, we will learn how to find the area of a trapezium using C Programming language.
A Trapezium is a quadrilateral having two parallel sides of unequal length and the other two sides are non-parallel.
- Area of Trapezium = ½ x (Sum of Parallel Sides) x Distance Between Them
We will be using this formula in our program to compute the area of trapezium
So, without further ado, let’s begin this tutorial.
C Program to Find Area of Trapezium
// C Program to find Area of Trapezium #include <stdio.h> int main(){ int b1, b2, height; float area; // Asking for input printf("Enter Base One: "); scanf("%d", &b1); printf("Enter Base Two: "); scanf("%d", &b2); printf("Enter the height: "); scanf("%d", &height); // Calculating area of trapezium area = 0.5 * (b1 + b2) * height; // Displaying output printf("Area of Trapezium: %.2f", area); return 0; }
Output
Enter Base One: 15
Enter Base Two: 25
Enter the height: 40
Area of Trapezium: 800.00
How Does This Program Work ?
int b1, b2, height; float area;
In this program, we have declared some int data type variables and one float data type variable.
// Asking for input printf("Enter Base One: "); scanf("%d", &b1); printf("Enter Base Two: "); scanf("%d", &b2); printf("Enter the height: "); scanf("%d", &height);
Then, the user is asked to enter the value of the two bases and the distance between them.
// Calculating area of trapezium area = 0.5 * (b1 + b2) * height;
We calculate the area of the trapezium using the formula:
- Area of Trapezium = ½ x (Sum of Parallel Sides) x Height
// Displaying output printf("Area of Trapezium: %.2f", area);
Finally, the result is displayed on the screen using printf() function.
Conclusion
I hope after going through this post, you understand how to find the area of a trapezium using C Programming language.
If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.
Also Read: