Demonstrate return values, converts pounds to kg - C++ Function

C++ examples for Function:Function Return

Description

Demonstrate return values, converts pounds to kg

Demo Code

#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;
}

Result


Related Tutorials