944,198 Members | Top Members by Rank

Ad:
  • C Code Snippet
  • Views: 2164
  • C RSS
0

Converting Fahrenheit-Celsius & Vice-Versa

by on May 15th, 2009
{-='Converting Fahrenheit-Celsius & Vice-Versa using Dev-C LaNGuaGe'=-}
C Code Snippet (Toggle Plain Text)
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. // Local Declarations
  6. float Celsius, Fahrenheit, Fahrenheit_1, Celsius_2;
  7.  
  8. // Statements
  9. printf("Enter the temperature in Fahrenheit: ");
  10. scanf("%f", &Fahrenheit);
  11. printf("Fahrenheit temperature is: %5.1f F\n\a", Fahrenheit);
  12.  
  13. Celsius = (100.0 / 180.0) * (Fahrenheit - 32);
  14.  
  15. printf("Celsius temperature is: %8.1f C\n\n\a", Celsius);
  16.  
  17. system("pause");
  18. system("cls");
  19.  
  20. printf("Enter the temperature in Celsius: ");
  21. scanf("%f", &Celsius_2);
  22. printf("Celsius temperature is: %8.1f C\n\a", Celsius_2);
  23.  
  24. Fahrenheit_1 = 32 + (Celsius_2 * (180.0 / 100.0));
  25.  
  26. printf("Fahrenheit temperature is: %5.1f F\a", Fahrenheit_1);
  27.  
  28. system("pause");
  29. return 0;
  30. }// main
Message:
Previous Thread in C Forum Timeline: Display the number of letters in each word typed
Next Thread in C Forum Timeline: Number of Rows (Reverse)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC