Numerical Methods Integration of given function using Simpsons 13 rule in C

Numerical Methods: Integration of given function using Simpson’s 1/3 rule in C

Source Code:

///integration of given function using Simpson's 1/3 rule
float y(float x){
    return 1/(1+x*x);

int main(){
    float x0,xn,h,s;
    int i,n;
    printf("Enter x0, xn, no. of subintervals: ");

    h = (xn - x0)/n;
    s = y(x0)+y(xn)+4*y(x0+h);

    for(i = 3; i<=n-1; i+=2){
        s += 4*y(x0+i*h) + 2*y(x0+(i-1)*h);

    printf("Value of integral is %6.4f\n",(h/3)*s);

    return 0;