C++ examples for Function:Function Return
Create a function to convert Fahrenheit to Celsius
#include <iostream> using namespace std; double tempvert(double); // function prototype int main()//from www .j av a 2 s . co m { const int CONVERTS = 4; // number of conversions to be made int count; double fahren; for (count = 1; count <= CONVERTS; count++) { cout << "\nEnter a Fahrenheit temperature: "; cin >> fahren; cout << "The Celsius equivalent is " << tempvert(fahren) << endl; } return 0; } // convert Fahrenheit to Celsius double tempvert(double inTemp) { return (5.0/9.0) * (inTemp - 32.0); }