DatCrazyMongoose
n00b
- Joined
- Oct 23, 2010
- Messages
- 8
Hello all!
This is my first post, so I hope I don't screw this up.
I've completed my homework program (more of a Linux compiler introduction than anything), but for some reason, I can't get the stupid thing to calculate correctly. The basic idea is to convert from Celsius to Fahrenheit, but you must use a separate function for the calculation.
Here is what I have so far. All it does is add 32 to the Celsius input.
Thanks for any help you can give.
'Goose
This is my first post, so I hope I don't screw this up.
I've completed my homework program (more of a Linux compiler introduction than anything), but for some reason, I can't get the stupid thing to calculate correctly. The basic idea is to convert from Celsius to Fahrenheit, but you must use a separate function for the calculation.
Here is what I have so far. All it does is add 32 to the Celsius input.
Code:
#include <iostream>
using namespace std;
int convert ( double );
int main()
{
double c = 0; // declare & initialize c
cout << "Please enter a temperature in degrees Celsius: "; // asks user for input
cin >> c; // user input assigned to variable c
cout << "That converts to " << convert( c ) << " degrees Fahrenheit." << endl;
system("PAUSE");
} // end function main
int convert( double celsius )
{
double fahrenheit = 0; // declare & initialize degrees Fahrenheit
fahrenheit = 9/5 * celsius + 32; // formula for converting Celsius to Fahrenheit
return fahrenheit; // returns converted result
} // end function convert
Thanks for any help you can give.
'Goose