title: How to add two sums, loop and add the first sum with with another?
body: <p>I'm trying find out how to add sum while doing a for loop, if that makes any sense? Like for instance:</p>
  
  <pre><code> float a = 0;
   int main(){
      float sum = 0;
  
      for(int n = 1; n &lt; 100; n++){ //n increases everytime
          sum = (1.0/(n * (n+1.0)));
          a = sum;
          cout &lt;&lt; a &lt;&lt; endl;
      }
  </code></pre>
  
  <p>How would I take the value of 'a' when n = 1, then add it to the value of 'a' when n = 2, then continuously do that? Then take the sum of the two "a's" and add it to when n = 3? Sorry if it's a bit confusing because I don't really get it myself... if it helps, here's an example:</p>
  
  <pre><code>(1/(1*2)) + (1/(2*3))+ (1/(3*4))+...(1/(n*(n+1)))
  </code></pre>