Results 1 to 15 of 88

Thread: C++ Help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    i n v i s i b l e Tech Admin o_O's Avatar
    Join Date
    Jun 2001
    Location
    New Zealand
    Posts
    2,957
    Blog Entries
    1

    FFXIV Character

    Humphrey Squibbles (Sargatanas)

    Default

    Code:
    int main() {
        float choice;
        cout << "This will convert fahrenheit to celsius.";
        cout << "What do you want to start with, enter your number than print enter.\n";
        cout << " 1. Fahrenheit\n";
        cout << " 2. Celsius\n";
        cin >> choice;
        
        if (choice == 1) {
            float fTemp;
            cout << "Input temperature in fahrenheit: ";
            cin >> fTemp;
            cout << toCelcius(fTemp);
        else {
            float cTemp;
            cout << "Input temperature in celcius: ";
            cin >> cTemp;
            cout << toFahrenheit(cTemp);
        }
    }
    
    float toCelcius(float fTemp)
    {
        return (fTemp-32)/1.8
    }
    
    float toFahrenheit(float cTemp);
    {
        return (1.8*cTemp)+32;
    }
    This could be one way to do it by passing variables. You need to define the variable outside of the function in order to pass it too the function.
    Last edited by o_O; 03-25-2006 at 09:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •