# Trapezoidal Rule C Program

By | July 31, 2016

Let’s understand the trapezoidal method in numerical analysis and implement trapezoidal rule in C programming language.

#### What is Trapezoidal Rule?

This numerical analysis method is used to approximating the definite integral. The trapezoidal numerical method works on the principle of straight line approximation.

This numerical method is also popularly known as Trapezoid Rule or Trapezium Rule.

This numerical analysis method is slower in convergence as compared to Simpson’s rule in numerical method.

#### Trapezium Rule Formula

This is a technique to approximate the definite integrals. It approximates the region under the graph of the function f(x) and calculates its area.

This method becomes more accurate and outputs perfect results when periodic functions are integrated over their periods.

Note: This C program to solve trapezoidal rule is compiled with GNU GCC compiler on Linux Ubuntu operating system. However, this code is compatible with all other operating systems.

If you try to compile this C program for Trapezium Rule in Linux, you will get the following error:

This is because the pow() method cannot be found in the library files. To overcome this error, you will have to explicitly include the math.h header file.

Compile the program using the following command:

#### Output

If you have any doubts about the implementation of Trapezoidal method in C programming, let us know about it in the comment section. Find more about it on Wikipedia.

NUMERICAL METHODS C PROGRAMS
Newton-Raphson Method C Program
Weddle’s Rule Algorithm C Program
Euler’s Method C Program
Secant Method C Program
Bisection Method C Program
Gauss Seidel Method C Program
Simpson’s 3/8th Rule C Program
Picard’s Method C Program
Regula Falsi Method C Program
Bisection Method Algorithm and Flowchart
Simpson’s 1/3rd Rule C Program

## 3 thoughts on “Trapezoidal Rule C Program”

1. Venkatesh Reddy

Is it necessary to use sqrt() function in another separate method in this trapezium theorem in c programming?

1. Tushar Soni Post author

No, it is not required. You can include it within the main() method. But, then the complexity of the main method woukd increase and it will be difficult to understand this c program.

2. Vedanr Mishra

This trapezium theorem is just so simple and easily understandable. Thanks.