I am having trouble solving this problem with an array. Here are the instructions:

You will write a program that evaluates the integral of sin(x) using the left-hand rectangle rule with

2000 subintervals, over 10 intervals. The intervals to test are [0, 1), [1, 2), …, [8, 9), [9, 10). You will

declare an array of type double that can hold 10 elements, and you will use this array to hold all 10

results you get from evaluating each interval.

Once you have calculated the integral as described for each interval, and the results are all stored in

your array, you will sort the array from smallest to largest, and output each element on separate lines.

Here is my code, although I know a lot of it is incorrect.

// I know that it is probably incorrect, can someone fix my code or help me out please? I am also having big problems sorting the values.Code:#include <iostream> #include <iomanip> #include <cmath> using namespace std; double integrate(double a, double b, int n); double f(double x); int main () { const int ARRAY_SIZE = 10; int numbers[ARRAY_SIZE]; int count; for(count=0; count < 10; count ++) cout << f(numbers[count]) << endl; } double integrate(double x1, double x2, int n) { double sum = 0, base; base = (x2-x1)/n; { sum = sum + f(x1); x1 = x1 + base; } return sum*base; } double f(double x) { return sin(x); }