C++ code

I need c++ code for simpson and trapezoidal rule? Tnx
I need a Ferarri, house with sea view and uzi.
ok
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

float trapezoidal(float, float, int);

float function_t(float, float, float);
float function_s(float, float, float);
void error_t(float, float, float, int);
void error_s(float, float, float, int);

main()
{ float x,
T,
S,
y,
a,
b;
int n;

printf("Input the lower value, a, to integrate:\n");
scanf("%f",&a);
printf("Input the upper value, b, to integrate:\n");
scanf("%f",&b);
printf("Enter even integer for n:\n");
scanf("%d",&n);

if(b>=a)
{
if(!(n%2))
{
T=trapezoidal(a,b,n);
S=simpson(a,b,n);
}
else
printf("n must be an even, positive integer");
}
else
printf("b must be greater than a");



system("PAUSE");
return 0;
}

float trapezoidal(float a, float b, int n)
{
float x,
T,
k;

x=(b-a)/(float)n;
k=function_t(a,b,x);
T=(x/2.0)*k;
error_t(a,b,T,n);
printf("%f\n",T);
return T;
}

float function_t(float a, float b, float x)
{
float i,
z=0.0,
T=0.0;

for(i=a;i<=b;i+=x)
{
if(i==a || i==B)
z=pow(i,2.0);
else
z=2.0*pow(i,2.0);
T=T+z;
z=T;
}
return T;
}

void error_t(float a, float b, float T, int n)
{
int K=2;
float E;

E=((float)K*pow((b-a),3.0))/(12.0*pow(n,2));
printf("Error %f\n",E);
}
the compiler show to me a mistake on S=simpson(a,b,n);? pls help me !!!!!
Topic archived. No new replies allowed.