/******************************************************************************************** 2_21r1.cpp Jim Millard for CO311
Solution rewritten to do work in a separate function Simple program that takes a temperature in celsius and converts it to fahrenheit for display. ********************************************************************************************/ #include <iostream> #include <string> using namespace std; float CtoF(const float C); int main() { float degC, degF; cout << endl << " Enter the Celsius temperature you wish to convert: " ; cin >> degC; degF = CtoF(degC) // \370 is the ASCII code for the degree symbol cout << endl << "\t" << degC << "\370C is the same as " << degF << "\370F." << endl; return 0; }
float CtoF(const float C) { return ((9./5.) * C + 32.); }