Skip to content

This repository contains a simple C program for converting temperatures between Fahrenheit and Celsius. It provides a console-based interface where users can select the conversion type, input a temperature value, and view the converted result.

Notifications You must be signed in to change notification settings

SafferStha/Temperature-Converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 

Repository files navigation

Temperature Converter Program

Overview

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.

Features

  1. Fahrenheit to Celsius Conversion
  2. Celsius to Fahrenheit Conversion

How to Use

  1. Compile the Program:
    To compile the program, you need a C compiler such as GCC:

    gcc temperature_converter.c -o temperature_converter
  2. Run the Program:
    After compiling, run the program using the following command:

    ./temperature_converter
  3. 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.
  4. 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.
  5. View Results:
    The program will display the converted temperature.

Program Flow

  1. 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).

  2. 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.
  3. 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 ]
  4. Display Results:
    After entering the temperature, the program calculates and displays the converted temperature.

Example Usage

Scenario 1: Fahrenheit to Celsius

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

Scenario 2: Celsius to Fahrenheit

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

Notes

  • Ensure to enter a valid choice (either 1 or 2) 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.

About

This repository contains a simple C program for converting temperatures between Fahrenheit and Celsius. It provides a console-based interface where users can select the conversion type, input a temperature value, and view the converted result.

Topics

Resources

Stars

Watchers

Forks

Languages