My objective is to estimate the numerical integral method using trapezoidal or Simpson's rule for n numbers of interval ( let n = 2,4,6,8,....20) and output should be given in three columns which n , S (Simpson's result) and E (Error)
Below are the code i tried to and it doesn't run .....
What is the value of n at the point when you declare your arrays x[] and y[] of size n+1?
Actually:
(a) this statement is illegal in standard c++, as the array size is not a compile-time constant;
(b) you don't need arrays anyway. Just call your function when you need to add values to the sum.
There are plenty of other errors from a numerical-integration perspective, including the fact that you don't reinitialise sum1 as 0 for each value of n, your loops are incorrectly nested, etc. However, it will be well-nigh impossible to sort this out unless you PUT YOUR CODE IN CODE TAGS.