- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion

# Program to calculate area and perimeter of Trapezium

Trapezium is a type of quadrilateral that has at least one pair of side parallel to each other. Area and perimeter of a trapezium can be found using the below formula,

Perimeter = sum of all sides

Area = ½ x (sum of the lengths of the parallel sides) x perpendicular distance between parallel sides

**Code logic** − The code will use 5 variables in as all sides of trapezium and one for the perpendicular distance between the two parallel side. For the area variable calculation we will take a float variable that will be initialised with the value. To calculate it we will use the formula “ ½ x (sum of length of parallel sides) x perpendicular distance between parallel sides ”. For the perimeter calculation a variable will be assigned the expression, “(Sum of all sides)”.

Below code displays the program to calculate the area and perimeter of a trapezium,

## Example

#include <stdio.h> int main() { int a = 2 , b = 3 , c = 5 , d = 4, h = 5; float area, perimeter; printf("The sides of trapezium are %d , %d , %d , %d

", a,b,c,d); printf("Distance between two parallel sides is %d

", h); perimeter = a+b+c+d; area = 0.5 * (a + b) * h ; printf("Perimeter of the trapezium is %.1f

", perimeter); printf("Area of the trapezium is: %.3f", area); return 0; }

## Output

The sides of trapezium are 2 , 3 , 5 , 4 Distance between two parallel sides is 5 Perimeter of the trapezium is 14.0 Area of the trapezium is: 12.500

- Related Articles
- Program to calculate area and perimeter of equilateral triangle
- Swift Program to Calculate Area and Perimeter of Equilateral Triangle
- Program to calculate area and perimeter of equilateral triangle in C++
- Calculate the area and perimeter of the following shapes:Q.1 Calculate the area of Square and rectangleQ.2 Calculate perimeter of Square and rectangle."\n
- How to calculate the area and perimeter of a circle in JavaScript?
- Java Program to Find the Area of a Trapezium
- Swift Program To Find The Area of a Trapezium
- Haskell Program to Find the Area of a Trapezium
- Kotlin Program To Find The Area of a Trapezium
- JavaScript program to find Area and Perimeter of Rectangle
- C Program for Area And Perimeter Of Rectangle
- Program to calculate area and perimeter of a rhombus whose diagonals are given\nWhat is rhombus in C++?
- Program to calculate the Area and Perimeter of Incircle of an Equilateral Triangle\nWhat is Equilateral Triangle in C?
- Program to calculate area of Enneagon
- Program to calculate Area Of Octagon