Programming Fundamentals/Variables/C++

variables.cpp

edit
// This program converts a Fahrenheit temperature to Celsius.
//
// References:
//     https://www.mathsisfun.com/temperature-conversion.html
//     https://en.wikibooks.org/wiki/C%2B%2B_Programming

#include <iostream>

using namespace std;

int main() 
{
    double fahrenheit;
    double celsius;
    
    cout << "Enter Fahrenheit temperature:" << endl;
    cin >> fahrenheit;

    celsius = (fahrenheit - 32) * 5 / 9;

    cout << fahrenheit << "° Fahrenheit is " << celsius << "° Celsius" << endl;

    return 0;
}

Try It

edit

Copy and paste the code above into one of the following free online development environments or use your own C++ compiler / interpreter / IDE.

See Also

edit