//********************************************************
//
// C Midterm - Question 7
//
// Name: Maya Mahin
//
// Class: C Programming, Spring 2025
//
// Date: March 23, 2025
//
// Description: Program which facilitates the conversion of fahrenheit to
// celsius temperatures and vice versa
//
//********************************************************
#include <stdio.h>
float toCelsius(float fahrenheitTemp);
float toFahrenheit(float celsiusTemp);
int main(void) {
float celsiusRetVal=toCelsius(32);
printf("The temperature in Celsius is: %.1f\n", celsiusRetVal
);
float fahrenheitRetVal=toFahrenheit(0);
printf("The temperature in Fahrenheit is: %.1f\n", fahrenheitRetVal
);
return 0;
}
//**************************************************************
// Function: toCelsius
//
// Purpose: Receives a temperature in fahrenheit, converts it
// to Celsius and returns the converted value
//
// Parameters:
//
// temp - input temperature in fahrenheit
//
// Returns: temp_convert - input temperature in celsius
//
//**************************************************************
float toCelsius(float fahrenheitTemp){
float celsiusTemp=(fahrenheitTemp - 32) * 5/9;
return celsiusTemp;
}
//**************************************************************
// Function: toFahrenheit
//
// Purpose: Receives a temperature in celsius, converts it
// to Fahrenheit and returns the converted value
//
// Parameters:
//
// temp - input temperature in celsius
//
// Returns: temp_convert - input temperature in fahrenheit
//
//**************************************************************
float toFahrenheit(float celsiusTemp){
float fahrenheitTemp=(celsiusTemp - 32) * 5/9;
return fahrenheitTemp;
}