// template for the two functions and the program itself
#include <stdio.h>
// function prototypes
float toCelsius (float theFahrenheitTemp);
float toFahrenheit (float theCelsiusTemp);
int main ()
{
int i; // loop index
printf("\n Celsius Fahrenheit"); //table header printf("\n _______ __________");
//loop to print Celsius to Fahrenheit
for (i = 0; i < 101; i++)
{
printf("\n %d %0.1f", i
, toFahrenheit
(i
)); }
// end loop 1
int x;
printf("\n Fahrenheit Celsius"); //table header printf("\n __________ _______"); for (x = 32; x < 213; x++)
{
printf ("\n %d %0.2f", x
, toCelsius
(x
)); }
// end loop 2
}
//********************************************************
// Function: toCelsius
//
// Purpose: convert a Fahrenheit temperature to Celcius
//
// Parameters - theFahrenheitTemp
//
// Returns: float
//********************************************************
float toCelsius (float theFahrenheitTemp)
{
float result;
result = (((theFahrenheitTemp - 32) * 5) / 9);
return result;
}// toCelsius
//********************************************************
// Function: toFahrenheit
//
// Purpose: convert a Celsius temperature to Fahrenheit
//
// Parameters: - theCelsiusTemp
//
// Returns: float
//********************************************************
float toFahrenheit (float theCelsiusTemp)
{
float result;
result = (((theCelsiusTemp / 5) * 9) + 32);
return result;
}// toFahrenheit
Ly8gdGVtcGxhdGUgZm9yIHRoZSB0d28gZnVuY3Rpb25zIGFuZCB0aGUgcHJvZ3JhbSBpdHNlbGYKI2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBmdW5jdGlvbiBwcm90b3R5cGVzCmZsb2F0IHRvQ2Vsc2l1cyAgICAoZmxvYXQgdGhlRmFocmVuaGVpdFRlbXApOwpmbG9hdCB0b0ZhaHJlbmhlaXQgKGZsb2F0IHRoZUNlbHNpdXNUZW1wKTsgCgppbnQgbWFpbiAoKQp7CglpbnQgaTsgIC8vIGxvb3AgaW5kZXgKCXByaW50ZigiXG4gQ2Vsc2l1cyAgICAgRmFocmVuaGVpdCIpOyAvL3RhYmxlIGhlYWRlcgoJcHJpbnRmKCJcbiBfX19fX19fICAgICBfX19fX19fX19fIik7CgkKCS8vbG9vcCB0byBwcmludCBDZWxzaXVz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