<p>There are plenty of different ways to write a program for a particular task. Let\'s try a variation on the temperature converter.</p>
<pre>   #include &lt;stdio.h&gt;

   /* print Fahrenheit-Celsius table */
   main()
   {
       int fahr;

       for (fahr = 0; fahr &lt;= 300; fahr = fahr + 20)
           printf(\"%3d %6.1f\\n\", fahr, (5.0/9.0)*(fahr-32));
   }
</pre>
<p>This produces the same answers, but it certainly looks different. One major change is the elimination of most of the variables; only <tt>fahr</tt> remains, and we have made it an <tt>int</tt>. The lower and upper limits and the step size appear only as constants in the <tt>for</tt> statement, itself a new construction, and the expression that computes the Celsius temperature now appears as the third argument of <tt>printf</tt> instead of a separate assignment statement.</p>
<p>This last change is an instance of a general rule - in any context where it is permissible to use the value of some type, you can use a more complicated expression of that type. Since the third argument of <tt>printf</tt> must be a floating-point value to match the <tt>%6.1f</tt>, any floating-point expression can occur here.</p>
<p>The <tt>for</tt> statement is a loop, a generalization of the <tt>while</tt>. If you compare it to the earlier <tt>while</tt>, its operation should be clear. Within the parentheses, there are three parts, separated by semicolons. The first part, the initialization</p>
<pre>   fahr = 0
</pre>
<p>is done once, before the loop proper is entered. The second part is the test or condition that controls the loop:</p>
<pre>   fahr &lt;= 300
</pre>
<p>This condition is evaluated; if it is true, the body of the loop (here a single <tt>ptintf</tt>) is executed. Then the increment step</p>
<pre>   fahr = fahr + 20
</pre>
<p>is executed, and the condition re-evaluated. The loop terminates if the condition has become false. As with the <tt>while</tt>, the body of the loop can be a single statement or a group of statements enclosed in braces. The initialization, condition and increment can be any expressions.</p>
<p>The choice between <tt>while</tt> and <tt>for</tt> is arbitrary, based on which seems clearer. The <tt>for</tt> is usually appropriate for loops in which the initialization and increment are single statements and logically related, since it is more compact than <tt>while</tt> and it keeps the loop control statements together in one place.</p>