This is a C Program to find area of trapezium.
This C Program calculates the area of trapezium.
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.
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; }
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.
Area = (1/2) * (a + b) * h.
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
- Watch Advanced C Programming Videos
- Practice BCA MCQs
- Check Computer Science Books
- Check C Books
- Apply for C Internship