#include <stdio.h>
#include<math.h>
#define f(x) 1/(1+pow(x,2))
int main()
{
int n;
double a,b,h,x,sum=0,ans,r;
printf("Enter the No. of N: ");
scanf("%d",&n);
printf("Enter the value of a and b: ");
scanf("%lf %lf",&a,&b);
h = (b-a)/n;
sum = f(a)+f(b);
for (int i = 1; i < n; i++)
{
r=a+i*h;
sum=sum+2*f(r);
}
ans = sum*h/2;
printf("%.4lf",ans);
return 0;
}
Comments
Post a Comment