title: How Can I Stop Newline at the Very End of a Loop?
body: <p>I have a programming assignment for class where the output must match exactly the contents of a file. For the problem, I have to use a loop that will continuously print out values with a specified format. My problem is stopping the last newline character from occurring when the loop is completed.</p>
  
  <p>Because of class policies, I can not include my actual code or the end goal that I am trying to accomplish, but let's say I am trying to print out the factorial of a number using a for-loop. I want to have the answers separated by line EXCEPT I don't want the last one to start a new line under it. How can I solve this problem without stopping the new early or having to create another loop afterwards?</p>
  
  <pre><code>int count; 
  int number; // some random value
  int sum = 1;
  
  for(count = 1; count &lt;= number; count++)
  {
    sum *= count;
    printf("Current Sum: %d\n", sum);
  }
  </code></pre>
  
  <p>Let's say the number is 3.
  I expect the output: </p>
  
  <pre><code>Current Sum: 1
  Current Sum: 2
  Current Sum: 6 //ends here, no newline
  </code></pre>
  
  <p>However, I get:</p>
  
  <pre><code>Current Sum: 1
  Current Sum: 2
  Current Sum: 6
                 //new line that I don't want
  </code></pre>