Thursday, 24 January 2013

celcius function

#include <iostream>
using namespace std;
int main()

{
    cout << "C to F\n";
    for (int celcius=0; celcius<=100; celcius++)
    {
        cout << celcius << "=  "<<  (celcius * 1.8) + 32 << endl;
    }

    char option;
    float degrees;

    cout << "Press 1 or 2 to convert From :" << endl;

    cout << "[1] Celsius to Fahrenheit" << endl;

    cout << "[2] Fahrenheit to Celsius" << endl;



    cin >> option;



    if (option == '1')

    {

        cout << "Please enter the number of Celsius Degrees:" << endl;

        cin >> degrees;

        float fahren = (degrees * 1.8) + 32;

        cout << degrees << " degrees Celsius is " << fahren << " degrees Fahrenheit" << endl;

    }

    else

    {

        cout << "Fahrenheit to Celsius" << endl;

        cin >> degrees;

        float celsius = (degrees - 32) / 1.8;

        cout << degrees << "degrees Fahrenheit is " << celsius << "degrees Celsius" << endl;

    }



    return 1;

}

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Enterprise Project Management