Sorry, I'm quite new to this, but could someone explain to me why the function pause() works perfectly in this instance:
Code:
#include <iostream>
using namespace std;
float tempConvert(float);
void pause(void);
int main(int argc, char* argv[])
{
pause();
return 0;
}
void pause()
{
cout<<endl<<"In pause()...";
cin.get();
}
float tempConvert(float tempFarenheit)
{
float tempCel;
tempCel=((tempFarenheit-32)*5)/9;
return tempCel;
}
But not in this case:
Code:
#include <iostream>
using namespace std;
float tempConvert(float);
void pause(void);
int main(int argc, char* argv[])
{
float tempFer;
cout<<"Enter the temperature in Fahrenheit: ";
cin>>tempFer;
cout<<endl<<"The temperature in Celcius is: "<<tempConvert(tempFer)<<" degrees.";
pause();
return 0;
}
void pause()
{
cout<<endl<<"In pause()...";
cin.get();
}
float tempConvert(float tempFarenheit)
{
float tempCel;
tempCel=((tempFarenheit-32)*5)/9;
return tempCel;
}
What happens is that it will wait for the user to enter something in the first code segment I posted, but in the second one it will display "In pause()..." but won't wait for the user to input something.