Infolinks

Breaking

Adsense

Sunday, January 24, 2016

PHP CELSIUS TO FAHRENHEIT: Celsius and Fahrenheit Converter Code

Hi there! The following tutorial will introduce you to one of the most common problems encountered in programming subjects. Later on, I will provide set of activities and quizzes for you to practice on to improve your programming skills.

A temperature converter is just one of the exercises given by most programming instructors. Some other exercises are the following:
  1.  Identify if odd or even number
  2.  Display numbers using a for loop
  3.  Solve for the area of a triangle
  4. Fibonacci Series


and many more. These are just some of the activities that I posted here in my blog. You can visit the links if you want.

This article will create a simple temperature converter from fahrenheit to celsius and vice versa. We will be using the following formula:

Visit my post about Celsius to Fahrenheit in Java here.

Formula Celsius and Fahrenheit Converter


C  x  9/5 + 32 = F
(F  -  32)  x  5/9 = C

First, we will convert Celcius to Fahrenheit. Let's try to convert 32 degrees Celsius to degrees Fahrenheit.

PHP Code Celsius and Fahrenheit Converter

Celsius to Fahrenheit

<?php
$c=32;
$f=$c*9/5+32;
echo $f."F";
?>

Fahrenheit to Celsius

<?php
$f=89.6;
$c=($f-32)*5/9;
echo $c."C";
?>

Output Celsius and Fahrenheit Converter







Try our Celsius to Fahrenheit Converter in PHP Live here!



Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php and mysql here in my blog. Watch out for more upcoming tutorials related to blogging and programming. Good day! ^_^

PHP CELSIUS TO FAHRENHEIT: Celsius and Fahrenheit Converter Code

No comments:

Post a Comment

Adbox