home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-SSP.ARJ / TPZOD.C < prev    next >
Encoding:
Text File  |  1984-06-28  |  431 b   |  23 lines

  1.    tpzod (m,xo,xh,y,tpa)
  2.  
  3.       /*to evaluate the definite integral of a function */
  4.       /*using the Trapezoidal Rule.                     */
  5.  
  6.       int m;
  7.       float xo,xh,y[],*tpa;
  8.  
  9.    {
  10.       int i,tm;
  11.       float di,ar;
  12.  
  13.       tm = m - 1;
  14.       di = (xh - xo)/(tm*2.);
  15.       *tpa = 0.;
  16.  
  17.       for(i = 0; i <= m-2; i++)
  18.       {
  19.        ar = di * (y[i] + y[i + 1]);
  20.        *tpa = *tpa + ar;
  21.       }
  22.    }
  23.