Ideally, some of the content of my Fahrenheit function should be placed in the main function but wanted to try something out. I asked for the user input in the Fahrenheit function and after this, I called the Fahrenheit function after the cout
statement. I expected the "Your temperature..." string to display first nevertheless it asked for the input before proceeding to print the string. Why is this so?
#include <iostream>
using namespace std;
int FahrenheitConv();
int main ()
{
cout << "Your temperature in Fahrenheit is "<< FahrenheitConv();
return 0;
}
int FahrenheitConv()
{
double centigrade;
cout << "What is your temperature in centigrade: ";
cin >> centigrade;
double fahrenheit = (1.8) * (centigrade ) + 32;
return fahrenheit;
}