title: c++ cin value returning 0 instead of the input value
body: <p>Hi I am extremely new to c++. Working on an assignment where I need to add up all numbers of input then display the numbers next to eachother with the sum.</p>
  
  <p><strong>example:</strong><br>
  input: 1234, output : 1 2 3 4  10</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      int myNum;
      int total = 0;
      int digit;
  
      cout &lt;&lt; "Enter a number" &lt;&lt; endl;
      cin &gt;&gt; myNum;
  
      while(myNum &gt;0)
      {
          digit =myNum %10;
          myNum/=10;
          total += digit;
  
      }
      while(myNum &lt;0) {
          digit =myNum %10;
          myNum /=10;
          total +=digit;
      }
  
      cout &lt;&lt; "The sum of digit is:" &lt;&lt; myNum &lt;&lt; total &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>The second while loop was to deal with negative numbers, but down on the <code>cout</code> when I put <code>myNum</code> to print the value I input it just prints <code>0</code> in front of the total, any reason the values aren't being carried over or how I could go about getting it to carry over?</p>