Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- double integral(int, int, double, double (*f)(double));
- double fun(double);
- int main()
- {
- int a, b;
- double epsil = 0.001;
- cout << "Please, enter a: ";
- cin >> a;
- cout << "Please, enter b: ";
- cin >> b;
- cout << "Integral = " << integral(a, b, epsil, fun) << endl;
- return 0;
- }
- double fun(double x)
- {
- return x;
- }
- double integral(int a, int b, double epsil, double (*f)(double))
- {
- double s = 0;
- for (double x = a; x < b; x += epsil)
- s += fun(x+epsil);
- return fabs(s)*epsil;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement