### Temperature Conversion using Module

Struggling with getting my int main to use the equation in my module

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253`` `````` #include #include #include using namespace std; void showF(float fahrenheit , float celsius) ; int main() { float fahrenheit = 0; float celsius = 0; // Input Block cout << "Please enter your temperature in Fahrenheit.\n"; cin >> fahrenheit ; showF( fahrenheit, celsius); //Output Block cout << std:: setprecision(2) << std::fixed; cout << fahrenheit <<" degrees fahrenheit is equal to " << celsius << " degrees"<< endl; system ("pause"); return 0; } void showF(float fahrenheit , float celsius) { celsius = ((fahrenheit - 32) * 5) / 9; } ``````
Actually solved the problem if anyone else is another struggling beginner. i put the change below

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

void showF(float fahrenheit , float celsius) ;

int main()
{

float fahrenheit = 0;
float celsius = 0;

// Input Block
cout << "Please enter your temperature in Fahrenheit.\n";
cin >> fahrenheit ;

showF( fahrenheit, celsius);

system ("pause");

return 0;

}

void showF(float fahrenheit , float celsius)
{

celsius = ((fahrenheit - 32) * 5) / 9;

//Output Block
cout << std:: setprecision(2) << std::fixed;

cout << fahrenheit <<" degrees Fahrenheit is equal to " << celsius << " degrees Celsius. "<< endl;

}
Hello hdbuck2,

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.

Doubles are preferred over floats.

There are two other ways to solve your original problem.

1. Have the function celsius. `double showF( double const fahrenheit, double const celsius);`

or

2. Pass celsius by reference. `void showF( double const fahrenheit, double& celsius);`

Hope that helps,

Andy
Topic archived. No new replies allowed.