I am trying to write a program that uses Simpson's rule and Trapezoidal rule from a fixed array. But I am having trouble integrating the array into the rules.

Here is the code

#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <math.h> //Function prototypes double f_value (double x); int main (void){ int k; double f[21], xx[21], del_x, x, s_value, t_value; del_x=0.05; for (k=0, x=0.; k<=20; k++){ xx[k]=x; f[k]=f_value(x); x+= del_x; } printf (" x f(x)\n"); for(k=0; k<21; k++) printf ("%8.2f %15.4e\n", xx[k], f[k]); /*trapezoidal rule*/ t_value= /*Simpson's rule*/ s_value= return; } double f_value (double x) { double fx; fx=sin(x)* exp(-0.5 *x*x); return fx; }

This post has been edited by **timwonderer**: 02 December 2010 - 01:39 PM