Fahrenheit and Celsius table by while loop : While loop « Statement « PHP






Fahrenheit and Celsius table by while loop

 
$fahr = -50;
$stop_fahr = 50;

print '<table>';
print '<tr><th>Fahrenheit</th><th>Celsius</th></tr>';
while ($fahr <= $stop_fahr) {
    $celsius = ($fahr - 32) * 5 / 9;
    print "<tr><td>$fahr</td><td>$celsius</td></tr>";
    $fahr += 5;
}
print '</table>';
  
  








Related examples in the same category

1.A sample while loop that counts to 10
2.A while Statement
3.Approximating a square root
4.Convert the while statement into a for statement?
5.Create a while statement that prints every odd number between 1 and 49
6.while and loop counter
7.Infinite Loops
8.The do...while Statement
9.Printing a
10.A while Statement