title: C++ - Find numbers between first and last negative numbers in Array
body: <p>I got the question about finding the summary of numbers in Array between first and last negative numbers, here's my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main(){
  float a[] = { 1.5, 55, 5, 4.4,7.1,9,8,2,4.2, -3, -3.2, 5.2, -9 };
  float eq = 0;
  float sumofnums = 0;
  
  for (int g = 0; g &lt; 13; g++) {
  
      if (a[g] &lt; 0) {
          sumofnums = a[g];
          cout &lt;&lt; sumofnums &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>I want to find summary between first and last negative numbers, I tried the method: sumofnums+= a[g];  but the answer is -15.2 while actually it is -10.</p>