-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path11.cpp
More file actions
25 lines (23 loc) · 772 Bytes
/
11.cpp
File metadata and controls
25 lines (23 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
using namespace std;
int main() {
// Declare variables
float temperature, converted_temperature;
char conversion_direction;
cout << "Enter the temperature to convert: ";
cin >> temperature;
cout << "Enter the conversion direction (C to F or F to C): ";
cin >> conversion_direction;
//(temperature - 32.0) * 5.0 / 9.0;
if (conversion_direction == 'C') {
converted_temperature = (temperature * 9.0) / 5.0 + 32.0;
} else if (conversion_direction == 'F') {
converted_temperature = (temperature - 32.0) * 5.0 / 9.0;
} else {
cout << "Invalid conversion direction." << endl;
return 0;
}
// Print the converted temperature
cout << "The converted temperature is: " << converted_temperature << endl;
return 0;
}