// INTEGRATION
// Program 18 : To impliment Weddle's integration formula
// ---------------------------------------------------------

#include <stdio.h>
#include <conio.h>
#include <math.h>

#define F(x) (1.0/(1.0+x*x))

main()
{
	int i, n;
	double a, b, h, x, y = 0.0;
	
	printf(" Enter lower limit  : ");
	scanf("%lf", &a);
	printf(" Enter upper limit  : ");
	scanf("%lf", &b);	
	printf(" Enter number of subintervals : ");
	scanf("%d", &n);
	
	h = (b - a) / (double)(n);
	
	for( i=0, x=a; i<=n ; i++, x+=h)
	{
		if( i == 0 || i == n )
			y += F(x);
		else
		switch( i%6 )
		{
			case 1: y += 5.0 * F(x); break;
			case 2: y += 1.0 * F(x); break;
			case 3: y += 6.0 * F(x); break;
			case 4: y += 1.0 * F(x); break;
			case 5: y += 5.0 * F(x); break;
			case 0: y += 2.0 * F(x); break;
		}
	}
	
	y *= 3.0 * h / 10.0;
	
	printf("\n Value of integration = %.10f", y );
	getch();
}



Output