title: C ++ program for the area under a curve. (the upper limit)?
body: <p>This is what I have for the upper limit. My value for n is 5. But I think I messed up somewhere because when I calculate it out by hand its not the same value. Does anyone know whats wrong with my program? </p>
  
  <pre><code>#include&lt;iostream&gt; 
  #include&lt;stdlib.h&gt; 
  #include&lt;math.h&gt; 
  #include&lt;iomanip&gt; 
  #include&lt;fstream&gt; 
  
  using namespace std; 
  double f(double x) 
  { 
      return (0.6*pow(x,2)) +4; 
  } 
  int main ( ) 
  { 
  
      double a, b, delx, x, area; 
      int n; 
  
      cout &lt;&lt; "Welcome. To begin, please enter a value for 'a' followed by a value for 'b'. \n"; 
      cin&gt;&gt;a&gt;&gt;b; 
      cout &lt;&lt; "You have entered a = " &lt;&lt; a&lt;&lt;" &amp; b = " &lt;&lt;b &lt;&lt;". Now, input an n value \n"; 
      cin &gt;&gt;n; 
  
      delx = (b-a)/n; 
      area = 0; 
  
      for (int i=0;i&lt;=n;i++) 
      { 
          area = area + f(a+i*delx)*delx; 
      } 
  
      cout &lt;&lt; "The area under the curve of f(x) = 0.6x^2 + 4 is "; 
      cout &lt;&lt; setprecision(5) &lt;&lt; area; 
  
  
      system ("pause"); 
  
  }
  </code></pre>