-moz-user-select:none; -webkit-user-select:none; -khtml-user-select:none; -ms-user-select:none; user-select:none;

Monday, 13 April 2015

Temperature conversion using "switch" statement

Hello and Asalam o Alikum. I hope you all are fine by the grace of Allah Almighty .
Today I am here with an important program that is related to temperature conversion using "switch" statement.

Explanation


As I have discussed in my previous blogs that a switch statement is used to test different condition.So,in the below mentioned program, there would be two choices before the user. If the user enters "1",then it will ask him to enter the temperature in celsius. It then converts it into fahrenheit according to the formula

f=c*9/5+32
Suppose the user enters "37" as input.So,
f=37*9/5+32
 =98.599998


. If the user enters "2",then it will ask him to enter the temperature in fahrenheit. It then converts it into celsius according to the formula 

c=(f-32)*5/9
Suppose the user enters "98.599998" as input.So,
c=(98.599998-32)*5/9
 =37


. So,this  is the logic on which this program works.

Below is the source code of this program.

Source code


Output

No comments:

Post a Comment