GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Oct-2008, 15:57
split71 split71 is offline
New Member
 
Join Date: Oct 2008
Posts: 6
split71 is an unknown quantity at this point

Getting an 'Undeclared Identifier' Error


This is a assignment for my programming class and i can't seem to figure out why it's not working. getting two errors.

error C2065: 'resultCF' : undeclared identifier
error C2065: 'resultFC' : undeclared identifier

here's the code..
CPP / C++ / C Code:
#include <iostream>

using namespace std;

float CtoF(float);
float FtoC(float);




int main()
{
int choice;
float degF, degC;
bool startOver = true;


do
{
cout << "Please select from the following: \n";
cout << "Celsius-to-Fahrenheit [1], Fahrenheit-to-Celsius[2], Quit [3]: ";

cin >> choice;

if ((choice > 3) || (choice <= 0))
{
do
{
cout << "Incorrect choice. Try again.\n";
cout << "Please select from the following: \n";
cout << "Celsius-to-Fahrenheit [1], Fahrenheit-to-Celsius[2], Quit [3]: ";
cin >> choice;
}while ((choice > 3) || (choice <= 0));

}
if (choice == 1)
{
cout << "Enter the temperature value in degrees C to convert: ";
cin >> degC;
cout << "\nThe temperature you entered in C, " << degC << " is " << resultCF << " F\n\n";
}

if (choice == 2)
{
cout << "Enter the temperature value in degrees F to convert: ";
cin >> degF;
cout << "\nThe temperature you entered in F, " << degF << " is " << resultFC << " C\n\n";
}
if (choice == 3)
{
cout << "Goodbye!!!\n";
startOver = false;
}
}while (startOver == true);

return 0;
}

float CtoF(float degC)
{
float resultCF;

resultCF = 5.0*(degC-32.0)/9.0;

return resultCF;
}

float FtoC(float degF)
{
float resultFC;

resultFC = ((9.0/5.0)*degF)+32.0;

return resultFC;
} 
  #2  
Old 13-Oct-2008, 16:02
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 761
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Getting an 'Undeclared Identifier' Error


You'll notice that you use those variables in your cout<< statements. Maybe you should be calling the FtoC() or CtoF() functions instead.
  #3  
Old 13-Oct-2008, 16:10
split71 split71 is offline
New Member
 
Join Date: Oct 2008
Posts: 6
split71 is an unknown quantity at this point

Re: Getting an 'Undeclared Identifier' Error


just tried that and it's giving me some wacky numbers
  #4  
Old 13-Oct-2008, 16:48
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 586
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: Getting an 'Undeclared Identifier' Error


Quote:
Originally Posted by split71
just tried that and it's giving me some wacky numbers
Exchange the expressions used in functions CtoF() & FtoC().
  #5  
Old 13-Oct-2008, 19:12
split71 split71 is offline
New Member
 
Join Date: Oct 2008
Posts: 6
split71 is an unknown quantity at this point

Re: Getting an 'Undeclared Identifier' Error


I got it to work, i forgot to put in the CtoF(degC) notation i only had CtoF before. duhhhhh. lol
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two-Tier data dissemination code installation problem nidhibansal1984 Computer Software Forum - Linux 6 16-Sep-2007 10:13
Linked Lists advice request promsan C Programming Language 74 23-May-2007 08:29
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 11:25
Help with syntax errors PeteGallo C Programming Language 7 08-Aug-2005 20:30
Can enum have same name as class? crystalattice C++ Forum 3 08-Dec-2004 16:43

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:48.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.