?
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double definiteIntegral(int a, int b, double (*fun)(double)){
double sum = 0.0;
double dx = (double)(b - a) / 100000;
for(double i = a; i < b; i += dx){
sum += (*fun)(i) * dx;
}
return sum;
}
int main(){
cout<<setiosflags(ios::fixed)<<setprecision(2);
cout<<"Integral_{0}^{1} sin dx = "<<definiteIntegral(0, 1, sin)<<endl;
cout<<"Integral_{-1}^{1} cos dx = "<<definiteIntegral(-1, 1, cos)<<endl;
cout<<"Integral_{0}^{2} exp dx = "<<definiteIntegral(0, 2, exp)<<endl;
system("pause");
return 0;
}