There's no error. The code just stops after you enter the fahrenheit

#include <iostream>
#include <iomanip>

using namespace std;

//function prototypes
	void getFahrenheit(int &); 
	void calcCelsius(int, double &);
	void displayCelsius(double);

int main()
{	
	//declare variables
	int fahrenheit = 0;
	double celsius = 0.0;
	
	//get input item
	getFahrenheit(fahrenheit);

	//calculate Celsius
	calcCelsius(fahrenheit, celsius);

	//display output item
	cout << fixed << setprecision(0);
	displayCelsius(celsius);

    return 0;
}   //end of main function

//*****function definitions*****

void getFahrenheit(int &fah)
{
	cout << "Enter Degrees in Fahrenheit: ";
	cin >> fah;
} //end of getFahrenheit function

void calcCelsius (int fah, double &cel)
{
cel = ((5.0/9.0)* (fah - 32.0));
cin >> cel;
} //end of calcCelsius function

void displayCelsius(double celsius)
{
cout << fixed << setprecision(0);
cout << "Temperature in Celsius is: " << celsius << endl;
}

Recommended Answers

All 2 Replies

After you input the Fahrenheit temperature, you immediately call calcCelsius which contains a cin statement. If you type a second number and hit "enter" again it works. It doesn't really make sense to input the Celsius temperature though in calcCelcius, right?

In your calcCelsius() function I don't think that you want the line cin >> cel; since you are displaying it in the next function. This is what makes it seem like it "stops" when really its just waiting for input.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.