//nilai integral dengan metode trapesium
#include<stdio.h>
#include<conio.h>
#include<math.h>
float n_fungsi(float x);
main()
{
float a,x,b,h,f[12],hasil,sum;
int i,n;
clrscr();
printf("masukan nilai awal : ");scanf("%f",&a);
printf("masukan nilai akhir : ");scanf("%f",&b);
printf("berapa segmen : ");scanf("%d",&n);
h=(b-a)/n;
x=a;i=1;
sum=n_fungsi(x);
do
{
x += h;
sum += 2 * n_fungsi(x);
i += 1;
}
while(i<n);
x += h;
sum += n_fungsi(x);
hasil=h*sum/2;
printf("\nhasil nya : %f",hasil);
getche();
return 0;
}
float n_fungsi(float x)
{
float y;
y=(0.2) + 25*x - 200*pow(x,2) + 675*pow(x,3) - 900*pow(x,4)+ 400*pow(x,5);
return y;
}