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

  1.    plyint(a,nda,b,c,ans)
  2.  
  3.       /*this function computes the definite integral of any  */
  4.       /*single variable polynomial of the form               */
  5.       /*a(0)*x**nda + a(1)*x**(nda-1) + ... + a(nda).        */
  6.  
  7.      int nda;
  8.      float a[],b,c,*ans;
  9.  
  10.     {
  11.       int i,k;
  12.       float cc,bb,f,x;
  13.  
  14.       *ans = 0.0;
  15.       x = *ans;
  16.       k = nda;
  17.       f = 1.;
  18.       bb = b;
  19.       cc = c;
  20.  
  21.       for(i = 0; i <=nda; i++)
  22.       {
  23.        x = x + a[k]*(cc - bb)/f;
  24.        f = f + 1;
  25.        bb *= b;
  26.        cc *= c;
  27.        k--;
  28.       }
  29.      *ans = x;
  30.     }
  31.