include stdio include math include conio define 35 double func_1 doubl

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
#include <math.h>
#include <conio.h>
#define N 35
double func_1(double m)
{double y;
return y=sin(m)*sin(m)*sin(m);}
double func_2(double m)
{double y;
return y=(1-m);}
double Integral(double w,double q, double a, double b, double (*func)(double))
{float h,s,t;
int i;
h=(b-a)/q;
for (s=0,i=0;i<q;i++)
s+=func(a+h*i);
if (w) return s=h/s; else return s*=h;}
int main(void){
printf("Integral 1 = %lf\n",Integral(0,N,-3,1.5,func_1));
printf("Integral 2 = %lf\n",Integral(1,N,-0.5,3,func_2));
getch();
return 0;}