Math lab- Simpson's 1/3rd Rule

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

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

double y(double x)
{
    return (exp(x*sin(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<=n;i++)
    {
        if(i==0 || i==n)
        ans+=y((i*h)+x);
        else if((i%2)==0)
        ans+=2*y((i*h)+x);
        else
        ans+=4*y((i*h)+x);
    }
    ans=ans*h/3;
    printf("\nIntegration Result=%f\n",ans);


}



OUTPUT:-