Create a function to convert Fahrenheit to Celsius - C++ Function

C++ examples for Function:Function Return

Description

Create a function to convert Fahrenheit to Celsius

Demo Code

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

Result


Related Tutorials