#include #include // Parameter constants const double A = 0.0; // Lower bound of the integration interval const double B = 1.0; // Upper bound of the integration interval const int N = 10; // Number of subdivisions (higher = more accurate) // Function to integrate: f(x) = cos(x) double f(double x) { return cos(x); } int main() { // -------------------------------------------------- // Numerical integration using the trapezoidal method // -------------------------------------------------- const double delta = (B - A) / N; // Width of each trapezoid: Delta x double value = 0.0; // Final result (total area) for(int i=0; i