The Temperature Converter Program is a console-based application written in C that allows users to convert temperatures between Fahrenheit and Celsius. The program displays a welcome message, prompts users to select a conversion type, and then calculates and displays the result based on the input temperature.
- Fahrenheit to Celsius Conversion
- Celsius to Fahrenheit Conversion
-
Compile the Program:
To compile the program, you need a C compiler such as GCC:gcc temperature_converter.c -o temperature_converter
-
Run the Program:
After compiling, run the program using the following command:./temperature_converter
-
Choose Conversion Type:
The program will prompt you to choose one of the following conversion options:- Enter
1
for Fahrenheit to Celsius conversion. - Enter
2
for Celsius to Fahrenheit conversion.
- Enter
-
Input Temperature:
Depending on the conversion type selected, enter the temperature value:- For Fahrenheit to Celsius, enter the temperature in Fahrenheit.
- For Celsius to Fahrenheit, enter the temperature in Celsius.
-
View Results:
The program will display the converted temperature.
-
Welcome Message and Conversion Options:
Upon running the program, you will be greeted with a welcome message and a list of conversion options (Fahrenheit to Celsius or Celsius to Fahrenheit). -
User Input:
The program prompts you to select one of the two conversion options:- Enter
1
to convert Fahrenheit to Celsius. - Enter
2
to convert Celsius to Fahrenheit.
- Enter
-
Temperature Conversion:
- Fahrenheit to Celsius: The conversion formula used is: [ C = ((F - 32) * 5) / 9 ]
- Celsius to Fahrenheit: The conversion formula used is: [ F = (C × 9 / 5) + 32 ]
-
Display Results:
After entering the temperature, the program calculates and displays the converted temperature.
Welcome to the Temperature Converter Program!
Here is a list of conversions to choose from:
Enter 1 for Fahrenheit to Celsius.
Enter 2 for Celsius to Fahrenheit.
1
Please enter the Fahrenheit degree:
100
Celsius: 37
Welcome to Temperature Converter!
Here is a list of conversions to choose from:
Enter 1 for Fahrenheit to Celsius.
Enter 2 for Celsius to Fahrenheit.
2
Please enter the Celsius degree:
0
Fahrenheit: 32
- Ensure to enter a valid choice (either
1
or2
) when prompted for the conversion type. If an invalid choice is entered, the program will display an error message and prompt you to enter a valid choice again. - The program currently supports only temperature conversions (Fahrenheit ↔ Celsius).
- The program does not handle invalid temperature inputs (e.g., non-numeric values). It assumes that the user will enter valid numeric temperatures.
- Future enhancements may include support for Kelvin conversions or other temperature scales.