It looks like you're on the right track, so I'll give you a little push. But first, I want to direct your attention to your keyboard. Look on the left side, above the caps lock key. There's a wide button with an arrow and the word "tab" on it. You should learn to use it when writing code.

Code:

double integrate(double x1, double x2, int n)
{
double sum=0, base=(x2-x1)/n;
for (int i=0; i<n; ++i)
{
sum+=f(x1+i*base);
}
return sum*base;
}

Note that you might have written it like this:

Code:

double integrate(double x1, double x2, int n)
{
double sum=0, base=(x2-x1)/n;
for (; x1<x2; x1+=base)
{
sum+=f(x1);
}
return sum*base;
}

However, I like the first better because due to rounding error, you might not get exactly n intervals with the second version. I also don't know why you chose "base" as the name for that variable. I'd have called it dx or delta_x or something like that.