Hi, I am pretty new to C++ and I am wondering what is wrong with this code--
I am basically doing a reimanm sum with trapezoids. I think I have the idea down, but my answer always comes out to be zero. Have I made a mistake with the while loop? Should I not have set the area = to zero initially? This is for a homework assignment.
You enter two initial x values, then the y values for those x values are found from an equation (in the code). I'm calculating the area under the curve from xa to xb with step sizes of s.
xc is not initalized to any particular value, so I suspect the condition on line 25 is false when it is encountered the first time so the body of the loop is never executed.
Thank you- that helped me find my mistake (after almost an hour of frustrated looking haha). I should have set xc=0 initially, and xc should have been less than xb in the while loop- not greater than. Oh well, at least I'll remember to be more careful next time.