title: C Programming: Removing Unnecessary Commas From Result of Prefix Sum Code
body: <p>I recently made code in C that reads a set of numbers until zero (zero ends the number set) and prints its prefix sum:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  int main()
  {
      int x, sum;
      sum = 0;
      while(x)
      {
          scanf("%d", &amp;x);
          sum += x;
          if(x != 0)
          {
              printf("%d,", sum);    
          }
          else{
              break;
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>If I were to type <code>2 3 5 7 11 0</code>: It would print the following:</p>
  
  <pre><code>2,5,10,17,28,
  </code></pre>
  
  <p>I was wondering how to remove the comma by the number <code>28</code> or to add commas to numbers until the last number?</p>