Friday, March 8, 2013

Complete Code : Take temperature in Fahrenheit as input and convert it into Centigrade and Kelvin. Display the conversion results at the end.

Program Sample Output
 
Sample Input: (Note: Bold refers to user input)

Enter Temperature in Fahrenheit: 32

Sample Output:

Centigrade : 0.00 °C
Kelvin : 273.00 K

Note: The character ‘°’ should also be printed in the output.

CODE

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>

main()
{
      float fTemp=0;
      cout<<"Enter temp in Fahrenheit : ";
      cin>>fTemp;
      float cTemp=(fTemp-32)*5/9;
      float kTemp=cTemp+273;
      printf("\nTemp is Centigrade is %f %cC",cTemp,248);
      printf("\nTemp is Kelvin is %f %cC",kTemp,248);
      getche();
}

Download this project's executable file from HERE

NOTE:You will need Dev C++ or TC compiler to compile this code.

No comments:

Post a Comment