title: How do I use Do While to stop a loop?
body: <p>I am writing a simple program that takes an input and adds it to a sum and then prints it, but then asks for another input and also adds that to the sum. However when 0 is in the input, the program should stop. That part is not working, here is what I have tried.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  
  int main(){
  
  int n, summa, t;
  
  summa = 0;
  t=1;
  do{
  scanf(&quot;%d&quot;, &amp;n);
  if(n==0){t=0;
  }
  summa = n + summa;
  
  
  printf(&quot;%d\n&quot;, summa);
  
  }
  while(t == 0);{return 0;}
  return 0;}
  </code></pre>