#include<stdio.h>
#include<conio.h>
float f(float x)
{
return(1/(1+x*x));;
}
void main()
{
int i,n;
float x0,xn,h,y[2000],so,se,ans,x[2000];
printf("\n\n\t\t\t----Crazy Coders----\n\n");
printf("\n Enter values of x0(lower limit): ");
scanf("%f",&x0);
printf("\n Enter values of xn(upper limit): ");
scanf("%f",&xn);
printf("\n Enter values of h(intervals): ");
scanf("%f",&h);
n=(xn-x0)/h;
if(n%2==1)
{
n=n+1;
}
h=(xn-x0)/n;
printf("\n After calculating the value of n and h are : \n ");
printf("\t\tn = %d ",n);
printf("\t\th = %d ",h);
printf("\n Y values: \n");
for(i=0; i<=n; i++)
{
x[i]=x0+i*h;
y[i]=f(x[i]);
printf("\n %f\n",y[i]);
}
so=0;
se=0;
for(i=1; i<n; i++)
{
if(i%2==1)
{
so=so+y[i];
}
else
{
se=se+y[i];
}
}
ans=h/3*(y[0]+y[n]+4*so+2*se);
printf("\n The result is %f",ans);
getch();
}
OUTPUT :-
For Other Programs Visit The WebSite:- https://www.techapurba.com/
Follow Me On Social Media :-
Instagram link :- https://www.instagram.com/apurba_khanra/
INSTA photography page :- https://www.instagram.com/photo_mania_hub/
Twitter link : - https://twitter.com/ApurbaKhanra199
Facebook page link (Crazy Coders) :-https://www.facebook.com/codercrazy/?modal=admin_todo_tour
Insta photography link :- https://www.instagram.com/photo_mania_hub/
Facebook link :- https://www.facebook.com/profile.php?id=100009747586288
FB photography page :- https://www.facebook.com/photomaniahub/?modal=admin_todo_tour
For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/
0 Comments