#include #include double f(double x) { double fx, pi = 3.1415926535897932; fx = sin(pi*x); return (fx); } double findint(double xl, double xr) { double h, x1, x2, x3, find; h = xr - xl; x1 = xl + h*(1.0-sqrt(0.6))/2.0; x2 = xl + h/2.0; x3 = xl + h*(1.0+sqrt(0.6))/2.0; find = h*(5.0*f(x1)+8.0*f(x2)+5.0*f(x3))/18.0; return (find); } main(int argc, char** argv) { double xl, xr, h, total=0.0; int s, m; printf("Input the two end points for the integration -> "); scanf("%lf %lf",&xl,&xr); printf("Please enter the number of subintervals -> "); scanf("%d",&s); printf("xl and xr: %f %f \n",xl,xr); h = (xr-xl)/s; xr = xl + h; for (m = 0; m < s; m++) { total = total + findint(xl,xr); xl = xr; xr = xl + h; } printf("The estimate of the integral is %f \n",total); }