Results 1 to 3 of 3
  1. #1
    Nathan's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    In a magical place
    Posts
    6,113
    Reputation
    394
    Thanks
    363

    [Help] Celsius To Fahrenheit

    Hello everyone,

    I just started learning C++ and I was trying to make a Celsius To Fahrenheit converter, but I got an error.

    Here's the code:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
    	double C;
    	cout << "Enter your degrees in celsius: ";
    	cin >> C;
    	temp(C);
    	cout << "Done!";
    	cin.get();
    	cin.get();
    	return 0;
    }
    
    void temp(double ctemp)
    {
    	double F = ctemp * 1.8 + 32; 
    	cout << ctemp << " Celsius = " << F << "Fahrenheit.";
    }
    So what's wrong with this?

    The error said: error C3861: 'temp': identifier not found

    Thanks..

  2. #2
    aanthonyz's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Hitler's Minivan
    Posts
    483
    Reputation
    27
    Thanks
    83
    My Mood
    Relaxed
    Change your code to this:

    Code:
    #include <iostream>
    
    using namespace std;
    
    void temp(double ctemp);
    
    int main()
    {
    	double C;
    	cout << "Enter your degrees in celsius: ";
    	cin >> C;
    	temp(C);
    	cout << "Done!";
    	cin.get();
    	cin.get();
    	return 0;
    }
    
    void temp(double ctemp)
    {
    	double F = ctemp * 1.8 + 32; 
    	cout << ctemp << " Celsius = " << F << "Fahrenheit.";
    }
    You didnt declare this in the beginning of the program
    "The best way to predict your future is to create it."

    Contributions I made:

    DirectX E-Books
    Hacking Tools
    Hacking into a PC

    Need Help?
    Send me a PM, or send me a email at : aanthonyz10@gmail.com

    Click My Dragon:


  3. #3
    Threadstarter
    Still a Cookie at heart
    Donator
    Nathan's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    In a magical place
    Posts
    6,113
    Reputation
    394
    Thanks
    363
    Quote Originally Posted by aanthonyz View Post
    Change your code to this:

    Code:
    #include <iostream>
    
    using namespace std;
    
    void temp(double ctemp);
    
    int main()
    {
    	double C;
    	cout << "Enter your degrees in celsius: ";
    	cin >> C;
    	temp(C);
    	cout << "Done!";
    	cin.get();
    	cin.get();
    	return 0;
    }
    
    void temp(double ctemp)
    {
    	double F = ctemp * 1.8 + 32; 
    	cout << ctemp << " Celsius = " << F << "Fahrenheit.";
    }
    You didnt declare this in the beginning of the program
    Ow yeah thanks.. I forgot that