title: C loop until 0 is given
body: <p>I'm trying to make a loop that lets the user enter numbers one by each other and calculate the sum of all those numbers until the user enters 0 as an input. However, my code is running only once and then stops.</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      int i = 0;
      int num;
      int total = 0;
  
      printf(&quot;Give me a number \n&quot;);
      scanf(&quot;%d&quot;, num);
      
      if(num &lt; 0 &amp;&amp; num &gt; 0){
          printf(&quot;Give me a number \n&quot;);
          scanf(&quot;%d&quot;, num);
          total = total + num;
          i = i + 1;
      }
  
      printf(&quot;The total is %d&quot;, total);
  }
  </code></pre>