A
AsheeG87
Hey Everyone~
I'm still a C++ Rookie so please bear with me on this.
I'm doing a temperature conversion program with prototype functions.
Basicly, I was wondering if some of you would take a look at my code
and critique it for me. I'm mostly concerned with how prototype
functions work and if I designed them correctly in my code.
Your participation would be greatly appreciated!
My Code:
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
double FahrenheittoCelsius(double)= 0.0; //Function Prototype
double CelsiustoFahrenheit(double)= 0.0;
int _tmain(int argc, _TCHAR* argv[])
{
double tempFahrenheit, tempCelsius;
double temp;
char f;
char c;
cout << " Enter the Temperature: "; //Prompt user to enter temp
cin >> temp;
cout << " Fahrenheit or Celsius?"; // If user does not specify f or c
ask them
if (temp == f)
{
c = FahrenheittoCelsius;
cout << f " degrees Fahrenheit is" c " degrees celsius ";
cout << " Continue? ";
else
f = CelsiustoFahrenheit;
cout << c " degrees Celsius is " f " degrees Fahrenheit ";
cout << " Continue? ";
}
return temp;
}
double FahrenheitoCelsius (double f)
{
return (f - 32) * (5.0/9);
}
double CelsiustoFahrenheit (double c)
{
return (9/5.0 * c) + 32;
}
I'm still a C++ Rookie so please bear with me on this.
I'm doing a temperature conversion program with prototype functions.
Basicly, I was wondering if some of you would take a look at my code
and critique it for me. I'm mostly concerned with how prototype
functions work and if I designed them correctly in my code.
Your participation would be greatly appreciated!
My Code:
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
double FahrenheittoCelsius(double)= 0.0; //Function Prototype
double CelsiustoFahrenheit(double)= 0.0;
int _tmain(int argc, _TCHAR* argv[])
{
double tempFahrenheit, tempCelsius;
double temp;
char f;
char c;
cout << " Enter the Temperature: "; //Prompt user to enter temp
cin >> temp;
cout << " Fahrenheit or Celsius?"; // If user does not specify f or c
ask them
if (temp == f)
{
c = FahrenheittoCelsius;
cout << f " degrees Fahrenheit is" c " degrees celsius ";
cout << " Continue? ";
else
f = CelsiustoFahrenheit;
cout << c " degrees Celsius is " f " degrees Fahrenheit ";
cout << " Continue? ";
}
return temp;
}
double FahrenheitoCelsius (double f)
{
return (f - 32) * (5.0/9);
}
double CelsiustoFahrenheit (double c)
{
return (9/5.0 * c) + 32;
}