Trapezoidal Rule C Program

C Program To Implement Trapezoidal Rule

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.

Solve Trapezium Rule in C Programming

Must Read: Gauss Seidel Method C Program


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:

C Program To Implement Trapezoidal Rule using Function

Must Read: Newton-Raphson Method C Program


C Program To Implement Trapezoidal Rule using Function with Algorithm, Output, Algorithm

Let’s discuss more on trapezoidal method C program in the comment section below if you have any compilation errors and any doubts about the same.

For more information on this trapezoidal method in numerical analysis, check Wikipedia.

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.


Let's Discuss