PC Project cp3
PC Project cp3
#include <stdio.h>
int main() {
int choice;
float temperature;
printf("Temperature Converter\n");
printf("Select the conversion type:\n");
printf("1. Celsius to Fahrenheit\n");
printf("2. Celsius to Kelvin\n");
printf("3. Fahrenheit to Celsius\n");
printf("4. Fahrenheit to Kelvin\n");
printf("5. Kelvin to Celsius\n");
printf("6. Kelvin to Fahrenheit\n");
printf("Enter your choice (1-6): ");
scanf("%d", &choice);
return 0;
}
Explanation:
1. Functions: The program contains functions to convert between the different temperature
units:
• celsiusToFahrenheit(float celsius)
• celsiusToKelvin(float celsius)
• fahrenheitToCelsius(float fahrenheit)
• fahrenheitToKelvin(float fahrenheit)
• kelvinToCelsius(float kelvin)
• kelvinToFahrenheit(float kelvin)
Main Function:
• The user is asked to choose the type of conversion they wish to perform (1-6).
• The program reads the temperature value and performs the selected conversion.
• It then outputs the result in the corresponding unit.
Output