MCPcopy Create free account
hub / github.com/Rustam-Z/cpp-programming / main

Function main

Lab_02/01_temperature_converter.cpp:7–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5using namespace std;
6
7int main() {
8 float temp;
9 char unit;
10
11 cout << "Enter the temperature: ";
12 cin >> temp;
13
14 cout << "Enter the unit (C/F): ";
15 cin >> unit;
16
17 if (unit == 'C') {
18 cout << "The temperature in Fahrenheit is " << (temp * 9 / 5) + 32 << "F." << endl;
19 } else if (unit == 'F') {
20 cout << "The temperature in Celsius is " << (temp - 32) * 5 / 9 << "C." << endl;
21 } else {
22 cout << "Invalid unit." << endl;
23 }
24
25 return 0;
26}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected