PHP Practical Slip 2 Q.A

Write a PHP Script which will convert temperatures from Celsius(C) to Fahrenheit (F). (Hint: C=5.0/9(F-32).

<?php
// Given temperature in Celsius
$celsius = 30;

// Convert Celsius to Fahrenheit
$fahrenheit = (9/5) * $celsius + 32;

// Display Result
echo "Temperature in Celsius: " . $celsius . "°C<br>";
echo "Temperature in Fahrenheit: " . $fahrenheit . "°F";
?>

Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top