C program to convert temperature between Kelvin, Celsius and Farenheit

C program to convert temperature between Kelvin, Celsius and Farenheit

#include <stdio.h>

float toKelvin(int selector, float value);
float fromKelvin(int selector, float value); 

int main(){
	int from , to;
	float value;
	
	printf("TEMPERATURE CONVERSION\n");
	printf("========================\n");
	printf("Choose the unit to covert from : \n 1.Celcius\n 2. Farenheit\n 3. Kelvin\n");
	scanf("%d",&from);
	
	printf("Enter no of Unit to covert to : \n 1.Celcius\n 2. Farenheit\n 3. Kelvin\n");
	scanf("%d",&to);
	
	printf("Enter The value to convert: ");
	scanf("%f",&value);
	
	// first convert the input to Kelvin 
	value = toKelvin(from, value);
	
	// then convert the input from Kelvin to required units
	value = fromKelvin(to, value);
	
	printf("Converted Value : %f", value);
		
}

float toKelvin(int selector, float value){
	
	switch(selector) {
		case 1:
		return value + 273.15;
		
		case 2:
		return (value+459.67)*5/9;
		
		case 3:
		return value;
		
		default:
		return value;
	}
}

float fromKelvin(int selector, float value){
	
	switch(selector){
		case 1:
		return value-273.15;
		
		case 2:
		return value*9/5-459.67;
		
		case 3:
		return value;
		
		default:
		return value;
		
		}
}