-
Notifications
You must be signed in to change notification settings - Fork 0
/
temprature.cpp
36 lines (30 loc) · 961 Bytes
/
temprature.cpp
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
26
27
28
29
30
31
32
33
34
35
36
#include<iostream>
using namespace std;
int main()
{
float fahr, cel;
char option;
cout << "Choose from following option:" << endl;
cout << "1. Celsius to Fahrenheit." << endl;
cout << "2. Fahrenheit to Celsius." << endl;
cin >> option;
//option for converting celsius into fahernheit
if (option == '1')
{
cout << "Enter the temperature in Celsius: ";
cin >> cel;
fahr = (1.8 * cel) + 32.0; //temperature conversion formula
cout << "\nTemperature in degree Fahrenheit: " << fahr << " F" << endl;
}
//option for converting Fahrenheit into Celsius
else if (option == '2')
{
cout << "Enter the temperature in Fahrenheit: ";
cin >> fahr;
cel = (fahr - 32) / 1.8; //temperature conversion formula
cout << "\nTemperature in degree Celsius: " << cel << " C" << endl;
}
else
cout << "Error Wrong Input." << endl;
return 0;
}