fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. int main()
  5. {
  6. int n = 155;
  7. double a = 3.0, b = 17.0;
  8. double dx = (b - a) / n;
  9. double integral = 0.0;
  10. for (double x = a + dx / 2; x < b; x += dx)
  11. {
  12. integral += exp(x) / x * dx;
  13. }
  14. std::cout << integral << std::endl;
  15. return 0;
  16. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
1.51617e+06