C++ examples for Function:Function Creation
Using Variables with Functions
#include <iostream> //from w ww . j a v a 2s .c o m float convert(float); int main() { float fahrenheit; float celsius; std::cout << "Please enter the temperature in Fahrenheit: "; std::cin >> fahrenheit; celsius = convert(fahrenheit); std::cout << "\nHere's the temperature in Celsius: "; std::cout << celsius << "\n"; return 0; } // function to convert Fahrenheit to Celsius float convert(float fahrenheit) { float celsius; celsius = ((fahrenheit - 32) * 5) / 9; return celsius; }