Robson » Little Red Book » Temperature conversion #2

Chapter 1 - Question 6

Given the temperature in degrees Centigrade, compute the equivalent Fahrenheit value.

Solution 1

<?    // generate a random number, this will be the temperature in degrees centigrade    $centigrade = mt_rand(1, 100);        // this is the way to convert centigrade to fahrenheit    $fahrenheit = ($centigrade * 1.8) + 32;        // show the randomly generated centigrade and the fahrenheit equivalent    echo $centigrade . '  degrees Centigrade is ' . round($fahrenheit, 2) . ' degrees Fahrenheit';     ?>

Which produces:

90 degrees Centigrade is 194 degrees Fahrenheit

Log

© 2004-20 robson | cc unless stated