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

// double f(double y, double t)
// {
//     double out=0;
//     out = sin(50*t)*y+cos(50*t)*y*y;
//     return out;
// }


// int main()
// {
//     double y0=2;
//     double t0 = 1;
//     double delta  = 0.01;
//     int n = 100;
//     int i;
//     double y, t;

//     y=y0;
//     t=t0;

//     for(i=0;i<n;i++)
//     {
//         y=y + f(y, t)*delta;
//         t=t*delta;
//         printf("%f\n%f\n", t, y); // y t?

//     }


//     return 0;
// }

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

// double f(double y, double t)
// {
//     double out=0;
//     out = sin(50*t)*y+cos(50*t)*y*y;
//     return out;
// }

// void solvedWithPassByReference(double y0, double t0, double delta, int n, double *timeVals, double *yVals)
// {
//     int i;
//     double y, t;
//     y=y0;
//     t=t0;

//     for(i=0;i<n;i++)
//     {
//         y=y + f(y, t)*delta;
            
//         t=t*delta;
//         timeVals[i] = t;
//         yVals[i] = y;
// }

// int main()
// {
//     double y0 = 2;
//     double t0 = 1;
//     double delta  = 0.01;
//     int n = 100;
//     int i;
//     double y, t;

//     double ys[100];
//     double ts[100];

//     y=y0;
//     t=t0;

//     for(i=0;i<n;i++)
//     {
//         y = ny + f(y, t)*delta;
//         t=t*delta;
//         printf("%f\n%f\n", t, y);
//     }
//     // call the function
//     void solvedWithPassByReference(y0, t0, delta, n, ts, ys);
//     printf("\n\n print again\n\n");
//     for(i=0;i<n;i++)
//     {
//         printf("%f\t%f", ts[i], ys[i]);
//     }
//     return 0;
// }

//-------------------------------------------------------------------------

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

// typedef struct
// {
//     double t;
//     double y;
// }point;


// double f(double y, double t)
// {
//     double out=0;
//     out = sin(50*t)*y+cos(50*t)*y*y;
//     return out;
// }

// solvedWithPassByReference(double y0, double t0, double delta, int n, double *timeVals, double *yVals)
// {
//     int i;
//     double y, t;

//     y=y0;
//     t=t0;

//     for(i=0;i<n;i++)
//     {
//         y=y + f(y, t)*delta;
//         t=t*delta;
//         ts[i] = t;
//         ys[i] = y;
//     }
//     return p;
// }

// solvedWithPassByReturn(double y0, double t0, double delta, int n)
// {
//     int i;
//     double y, t;

//     y=y0;
//     t=t0;

//     for(i=0;i<n;i++)
//     {
//         y=y + f(y, t)*delta;
//         t=t*delta;
//         p[i] = t;
//         p[i] = y;
//     }
//     return p;
// }


// int main()
// {
//     double y0 = 2;
//     double t0 = 1;
//     double delta  = 0.01;
//     int n = 100;
//     int i;
//     double y, t;

//     double ys[100];
//     double ts[100];

//     point *q;

//     y=y0;
//     t=t0;

//     for(i=0;i<n;i++)
//     {
//         y = ny + f(y, t)*delta;
//         t=t*delta;
//         printf("%f\n%f\n", t, y);
//     }
//     // call the function
//     void solvedWithPassByRefernce(y0, t0, delta, n, ts, ys);
//     printf("\n\n print again\n\n");
//     for(i=0;i<n;i++)
//     {
//         printf("%f\t%f", ts[i], ys[i]);
//     }

//     q = solvedWithPassByReturn(y0, t0, delta, n);
//     printf("\nfor the 3rd time\n");
//     for(i=0;i<n;i++)
//     {
//         printf("%f\t%f", q);

//     return 0;
// }


#include <stdio.h>

double f(double x)
{
    double out = 0;
    out = x*x;

    return out;
}

double integrateF(double lowEnd, double highEnd, double delta)
{
    double out;
    int n;=1
    int i;
    n = (int)((highEnd - lowEnd)/delta);

    out = f(lowEnd)/2
    for(i=1;i<n;i++)
    {
        out = out+ f(lowEnd+n * delta);
    }
    out = out+ f(lowEnd+n * delta);
    out = out*delta;
    return out;
}



int main()
{
    printf("%f\n", integrate(0, 3, 0.0001));
    
    return 0;
}