title: integrating using midpoint method
body: <p>I need to make a C program that would calculate the integral of a third degree polynomial using the <strong>midpoint method</strong>.</p>
  
  <p>Basically integrating this: f(x) = mx^3 + nx^2 + px + q
  using the block/midpoint method.</p>
  
  <p>So far I have this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  int main(){
      char option;
      float m, n, p, q, a, b, N, S=0,T,h;//S for midpoint, T for Trap, h for interval length
      do{
          printf("\n Select one of following options:\n");
          printf("a)Enter new coefficients (m,n,p, and q)\n");
          printf("b)Enter the value for the range from a to b, and N, the number of intervals\n");
          printf("c)Calculate the integral from a to b\n");
          printf("d)Exit\n");
  
          option=getc(stdin);
          printf("You have selected option: \"%c\" \n", option);
  
          switch (option){
          case 'a':
              printf("Enter m,n,p,q (in this order):\n");
              scanf("%f%f%f%f", &amp;m,&amp;n,&amp;p,&amp;q);
              break;
          case 'b':
              printf("Enter the interval from a to b and the number of intervals N:");
              scanf("%f%f%f", &amp;a, &amp;b, &amp;N);
              break;
          case 'c':
              h = (b - a) / N;
              for (float i = a; i &lt; b - h; i + h){
                  S =+(m*pow(i, 3)) + n*pow(i, 2) + p*i + q;
              }
              S = S*h;
              printf("The integral using midpoint rule: %f", S);
              break;
          case 'd':
              printf("Exit.\n");
              break;
          default:
              printf("Invalid entry, try again... \n");
              break;
          }
      } while (option != 'd');
      return 0;
  }
  </code></pre>
  
  <p>this is the main algorithm I'm trying to use:</p>
  
  <pre><code>h = (b - a) / N;
              for (float i = a; i &lt; b - h; i + h){
                  S =+(m*pow(i, 3)) + n*pow(i, 2) + p*i + q;
              }
              S = S*h;
              printf("The integral using midpoint rule: %f", S);
              break;
  </code></pre>
  
  <p>but it's not working. It gets stuck in the loop part. Because after I input all the other variables and choose the c option, it just does nothing.</p>
  
  <p>The algorithm starts by finding the length of interval. Then the loop adds the function per the midpoint formula, and that's where I think I did something wrong.</p>