#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# trying to debug this and having trouble

Member Posts: 15
displays a Celsius temperature

#include
using namespace std;

//function prototypes
int getFahrenheit();
float calcCelsius(int);
int displayCelsius();

int main()
{
//declare variables
int fahrenheit = 0;
float celsius = 0.0;

//get input item
fahrenheit = getFahrenheit();

//calculate Celsius
celsius = calcCelsius(fahrenheit);

//display output item
cout << fixed;
cout << "Celsius: " << celsius << endl;
return 0;
} //end of main function

//*****program-defined functions*****

int getFahrenheit()
{
int tempF = 0;
cout << "Enter Fahrenheit temperature: ";
cin >> tempF;
return tempF;
} //end of getFahrenheit function

float calcCelsius(int tempFahrenheit)
{
float tempC = 0.0;
tempC = 5.0 / 9.0 * (tempFahrenheit - 32);
return tempC;
} //end of calcCelsius function

displayCelsius()
{
int temp;
cout << "Dipl temp: ";//display the temperture calculated from fehrenheit to celsius
return temp;//return celsius temperature
} //end of dsiplayCelsius function

• Member Posts: 16
: displays a Celsius temperature
:
: #include
: //using namespace std; <<<--- What's with this? I tried to delete it.
: //function prototypes
: int getFahrenheit();
: float calcCelsius(int);
: int displayCelsius();
:
: int main()
: {
: //declare variables
: int fahrenheit = 0;
: float celsius = 0.0;
:
: //get input item
: fahrenheit = getFahrenheit();
:
: //calculate Celsius
: celsius = calcCelsius(fahrenheit);
:
: //display output item
// cout << fixed;
//try thiss..
cout.precision(2);

: cout << "Celsius: " << celsius << endl;
: return 0;
: } //end of main function
:
: //*****program-defined functions*****
:
: int getFahrenheit()
: {
: int tempF = 0;
: cout << "Enter Fahrenheit temperature: ";
: cin >> tempF;
: return tempF;
: } //end of getFahrenheit function
:
: float calcCelsius(int tempFahrenheit)
: {
: float tempC = 0.0;
: tempC = 5.0 / 9.0 * (tempFahrenheit - 32);
: return tempC;
: } //end of calcCelsius function
:
: displayCelsius()
: {
: int temp;
: cout << "Dipl temp: ";//display the temperture calculated from fehrenheit to celsius
: return temp;//return celsius temperature
: } //end of dsiplayCelsius function
:
:
:

I have changed your code just take a look above.
• Member Posts: 127
Hi,

I replied to this thread on another message board!

• USAMember Posts: 0

______ // http://forcoder.org // free ebooks and video tutorials about { C#, Java, Objective-C, Python, MATLAB, Swift, R, PL/SQL, Visual Basic .NET, Delphi, JavaScript, C++, Perl, PHP, Ruby, Go, Scratch, C, Assembly, Visual Basic ABAP, COBOL, Alice, ML, Crystal, Fortran, Dart, Ada, Prolog, Scheme, Transact-SQL, Awk, FoxPro, Rust, Lua, F#, Hack, Lisp, Kotlin, Erlang, SAS, Clojure, D, VBScript, Scala, Julia, Logo, LabVIEW, Apex, Bash } ______________