Simple Temperature Conversion (C++)

This is a simple conversion of temperature i made a while ago, was just going through my archive and found it, thought i put it out here for display. Its quite easy to understand the syntax used. using only integers, you’ll be able to get the absolute value of temperature, whether Degree Celsius or Degree Fahrenheit. You can apply any other C++ variable depending on whether you want it to show you in decimal points.


// Temperature conversion in cpp.
// a simple temperature conversion program written by Charming Prince.
#include <iostream>
using namespace std;
int main ()
{
          int temp; // values to determine temperature
          int cel;  // temperature in degree celsius
          int fah; // temperature in degree fahrenheit
          int value;

    cout << "What do you want to convert? please select from below!" << endl;
     // Prompt User
    cout <<  " 1.Convert from Fahrenheit to Degree celsius. " << endl;
    cout <<  " 2.Convert from Degree celsius to Fahrenheit. " << endl;    
         cin >> value; // user selects
                   //a value by either pressing 1 or 2.
                 // validation of pressing  a correct number is determined.
    if ( value==1 )
    {
        cout << " Please insert a number to change from Fahrenheit to Degree Celsius " 
       << endl;
        cin >> temp;// prompts Value for user to enter
        cel = ((temp -32) * 5/9);
         cout << " Your value is,"<< cel << " degree celsius " 
        << endl; // result to be displayed
     }
     else if (value==2)
    {
        cout << " Please insert a number to change from Degree celsius to Fahrenheit " 
       << endl;
       cin >> temp;// prompts Value for user to enter
        fah = (temp * 9/5 + 32);
         cout <<" Your value is,"<< fah <<" degree fahrenheit" 
       << endl;// result to be displayed
    }
    else {
        cout << " You didn't make a selection yet?"; 
        //shows when any other value than 1 or 2 is pressed.
    }
return 0; // end of program
}

A free C++ Compiler is available online for download, Just Google Code-Block Compiler (simply click on the link to go to their download page) and you’ll have available links provided for you to be able to download it. its an open source application so it wouldn’t be a problem trying to download it.

No related content found.

0

About Charming Prince

Being a Web Developer/Web Author, i had an idea to disseminate my knowledge in the field of web development to other people by opening this online free tutorials on programming languages, in so doing, to share ideas where applicable...As well as to share ideas in related area pertaining to information dissemination and media such as Movies, Music , and Games. as per these are the areas which i like the most and i think most people do like this area as well, so I'll try to make my explanation short but concise...
This entry was posted in Programming and tagged , , , . Bookmark the permalink.

4 Responses to Simple Temperature Conversion (C++)

  1. you can use the codes above, modify it and make it unique on your own!…

  2. zerodtkjoe says:

    Thanks for the info

  3. Mskuto Falahwe says:

    Great script, shame about the output.

    Simple things please the simple minds….

    Hope someone finds a use for this useless crap

    What a waste of fucking time you wanker

  4. arielwoo says:

    Thank you for your guidance!^_^

Leave a Reply

Your email address will not be published. Required fields are marked *

Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar Custom avatar