0

I'm really confused as to how to set up this program. The program is to have a function "trap", so I'm guessing that means I have to include a function that solves the integral before my main function?

```
#include <stdio.h>
#include <math.h>
double f(double x)
{
return exp(-x*x);
}
double f(double x)
{
return exp(-x);
}
float a;
float b;
float x;
float h;
float sum;
float s;
int n;
int i;
int trapeze(int n, int i)
{
h=(b-a)/n;
s=(0.5*h)*(f(a)+f(b));
for (i = 1; i < n; i++)
{
sum = s+h*f(a+(i*h));
}
}
int main(void)
{
printf("Enter the number of intervals: ");
scanf("%d", &n);
return 0;
}
```

So basically we're given 2 functions: f(x) = e^(-x^2) and f(x) e^(-x). The program is suppose to solve both them them depending on number of interval the user inputs. I've sat here for 3 hours trying to figure this out, and I've been just throwing codes together. Hoping to get a good insight on how to better approach this. I believe I have the function that inputs the trapezoidal rule correctly.