Math lab- Simpson's 3/8th Rule



Implementation of Simpson's 3/8th Rule on function I=e^(x*sin(x)) dx?

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

double y(double x)
{
    return ((sin(x)/x)+(x*logf(x)));
}

main()
{
    float x=0,h,ans=0,l;

    int i,n;
    printf("\nEnter the initial value: ");
    scanf("%f",&x);
    printf("\nEnter the final value: ");
    scanf("%f",&l);
    printf("\nEnter the number of integrals: ");
    scanf("%d",&n);
    h=(l-x)/(n*1.0);
    for(i=0;i<=9;i++)
    {
        if(i==0 || i==n)
        ans+=y((i*h)+x);
        else if((i%3)==0)
        ans+=2*y((i*h)+x);
        else
        ans+=3*y((i*h)+x);
    }
    ans=(ans*3*h)/8;
    printf("\nResult=%f\n",ans);


}


OUTPUT:-