title: Are for loops and while loops always interchangeable
body: <p>I understand the concept of one having certain advantages over the other depending on the situation but are they interchangeable in every circumstance? My textbooks writes </p>
  
  <pre><code>for (init; test; step) {
      statements; 
  } 
  </code></pre>
  
  <p>is identical to </p>
  
  <pre><code>init; 
  while (test) { 
      statements; 
      step; 
  } 
  </code></pre>
  
  <p>How would I rewrite the following program in the for loop? I'm having trouble setting the value for the init and the test if i rework the following program into the for loop form.  </p>
  
  <pre><code>import acm.program.*;
  
  public class DigitSum extends ConsoleProgram{  
  public void run() {
       println("this program sums the digits in an integer");
       int n = readInt("enter a positive number: ");
       int dsum = 0;
       while ( n &gt; 0) {
         dsum += n % 10;
         n /=10;
       }
      }
     }
  </code></pre>