#include <iostream>
usingnamespace std;
// ConvertTemperature.cpp
int main()
{
// prototype
double convertTemperature(double); // function prototype
constint CONVERTS = 4; // number of conversions to be made
double fahrenheit;
double celsius;
for(int index = 0; index < CONVERTS; index++)
{
cout << "\nEnter a Fahrenheit temperature: ";
cin >> fahrenheit;
// function call
celsius = convertTemperature(fahrenheit);
cout << "The Celsius equivalent is "
<< celsius << endl;
}
cin.get();
return 0;
}
//-------------------------------------------------------------------
// Output Function - code the convertTemperature() function below
//-------------------------------------------------------------------
The following is my output code for this program...Am I close..?
1 2 3 4 5 6
double convertTemperature (double celsius = 5.0/9.0 * (fahrenheit - 32.0));
{
return celsius;
}
I feel a little bit more confident about this one...What do you guys think>\\?
In a function declaration or definition, what goes in the parentheses after the function name is a simple argument list. You cannot have calculations inside (except when calling the function).
Also, there is a semi-colon at the end, which cuts off the declaration from the function body.
Try rearranging thing like this:
1 2 3 4
double convertTemperature (double fahrenheit)
{ //Note how I didn't even need to declare a Celsius variable
return 5.0/9.0 * (fahrenheit - 32.0);
}
the second page you sent me was very useful thank you Daleth,...C++ just hasn't been my cup of tea.../: it sucks when your a networker and they make you take a damn class like this that doesnt mix with your major. But I guess it will help in becoming more of a all-round IT person...thnkx again..!