title: Incorrect sum when adding up numbers
body: <p>Ok, here's the code to add indefinite numbers and present the sum in c++. But error is that addition taking place is of first number and the last digits of all the other numbers. For example if i want to add <code>30 + 40 + 55 + 70</code>, my program counts <code>30 + 0 + 0 + 5 + 0 = 35</code>. What am I doing wrong?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      int num = 0;
      int sum = 0;
  
      cout &lt;&lt; "Please enter numbers you want to add and end with N or n: ";
  
      for (;;)
      {
          cin &gt;&gt; num;
          sum += num;
          cout &lt;&lt; endl;
  
          char indicator ('q');
  
          cin &gt;&gt; indicator;
          if (( indicator == 'n') || (indicator == 'N'))
              break;
  
      }
      cout &lt;&lt; "The sum is: " &lt;&lt; sum &lt;&lt; " ";
  
      return 0;
  }
  </code></pre>