C++ examples for Function:Function Return
Demonstrate return values, converts pounds to kg
#include <iostream> using namespace std; float lbstokg(float); //declaration int main()/*w w w .ja v a2 s . c o m*/ { float lbs, kgs; cout << "\nEnter your weight in pounds: "; cin >> lbs; kgs = lbstokg(lbs); cout << "Your weight in kilograms is " << kgs << endl; return 0; } // converts pounds to kilograms float lbstokg(float pounds) { float kilograms = 0.453592 * pounds; return kilograms; }