Saturday, May 31, 2014

Centigrade to Fahrenheit conversion

Script

#!/usr/bin/perl

print ("Enter the degrees in Centigrade: ");
$centigrade = <STDIN>;
chop ($centigrade);
$fahrenheit = $centigrade * 9/5 + 32;
print ($centigrade, " degree Centigrade is equivalent to ", $fahrenheit, " degree Fahrenheit \n" )


Execution

Enter the degrees in Centigrade: 100
100 degree Centigrade is equivalent to 212 degree Fahrenheit

Enter the degrees in Centigrade: 25
25 degree Centigrade is equivalent to 77 degree Fahrenheit

Enter the degrees in Centigrade: 37
37 degree Centigrade is equivalent to 98.6 degree Fahrenheit

Enter the degrees in Centigrade: 20
20 degree Centigrade is equivalent to 68 degree Fahrenheit

No comments:

Post a Comment