Answer to Question #347799 in C++ for Patt

Question #347799

Create a program of temperature conversion using basic program

1
Expert's answer
2022-06-06T08:36:02-0400
#include <iostream>

using namespace std;

int main()
{
    int a = 0;
    float cel, far = 0;
    cout << "What do you want to convert?\n";
    cout << "(0) Celsius to Fahrenheit | Fahrenheit to Celsius (1)\n";
    cin >> a;
    if (a)
    {
        cout << "Please enter a Fahrenheit value: ";
        cin >> far;
        cel = (far - 32) / 1.8f;
        cout << far << " degrees Fahrenheit is " << cel << " degrees Celsius";
        
    }
    else
    {
        cout << "Please enter a Celsius value: ";
        cin >> cel;
        far = cel * 1.8f + 32;
        cout << cel << " degrees Celsius is " << far << " degrees Fahrenheit";
    }


    return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS