Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Fahrenheit to Celsius conversion formula: F = C x 9/5 + 32
- Celsius on Fahrenheit conversion formula: C= ([°F] - 32) x 5/9
- */
- #include <stdio.h>
- #include <stdbool.h>
- #define getch
- #ifdef WIN32
- getch();
- #endif
- int main () {
- bool userChoice;
- printf ( "To convert Fahrenheit to Celsius, press 0 (zero), to convert Celsius to Fahrenheit, press 1!\n--> " );
- scanf ( "%i", &userChoice );
- if ( userChoice == 0 ) {
- FahrToCel ();
- }
- else if ( userChoice != 0 ) {
- CelToFahr ();
- }
- getch ();
- return 0;
- }
- int CelToFahr ( int celsius ) {
- printf ( "Insert temperature in Celsius:\n--> " );
- scanf ( "%i", &celsius );
- printf ( "%3d Celsius =%6.1f Fahrenehit\n", celsius, celsius * 9.0 / 5.0 + 32 );
- return 0;
- }
- int FahrToCel ( int fahr ) {
- printf ( "Insert temperature Fahreneheit:\n--> " );
- scanf ( "%i", &fahr );
- printf ( "%3d Fahrenheit =%6.1f Celsius\n", fahr, ( fahr - 32 ) * 5.0 / 9.0 );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement