Thread: Function: same 'ol Farenheit to Celsius

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    38

    Function: same 'ol Farenheit to Celsius

    I keep getting error c2064: term does not evaluate to a function taking 1 arguments. This is described as not pointing to a function. Doesn't Celsius point to the function? Searching didn't help because I couldn't find the type code I need.

    Code:
    #include <iostream>
    #include <conio.h>
    using namespace std;
    
    int main()
    {	
    	float FtoC, Farenheit;
    	float Celsius(float);
    	cout << "please enter the temperature in Farenheit: ";
    	cin >> Farenheit;
    	cout << endl;
    	FtoC = Celsius(Farenheit);
    	cout << endl;
    	cout << FarenheittoCelsius;
    	getch();
    	return 0;
    }
    
    
    	float Celsius(float F)
    	{	
    		return 5(F - 32) / 9;
    	}

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    You need to declare the Celsius function if you use it before you define it. Also, you need to add a * in the return of Celsius.
    Code:
    #include <iostream>
    #include <conio.h>
    using namespace std;
    
    float Celsius(float F);
    
    int main()
    {	
    	//snip
    	return 0;
    }
    
    
    float Celsius(float F)
    {	
    	return 5 * (F - 32) / 9;
    }
    [edit]Whoa...that's what I get for skimming over code. Check out this part of your main function:
    Code:
    	float Celsius(float); //what's this?
    	cout << "please enter the temperature in Farenheit: ";
    	cin >> Farenheit;
    	cout << endl;
    	FtoC = Celsius(Farenheit);
    	cout << endl;
    	cout << FarenheittoCelsius;  //this variable was never declared
    Last edited by pianorain; 04-21-2005 at 02:49 PM.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    38
    Thanks for the quick response.

    The missing * was the problem. I kept thinking mathmatically instead of computer.
    Last edited by MB1; 04-21-2005 at 03:11 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM