0% found this document useful (0 votes)
4 views

Cpp

Uploaded by

keshavpatel2287
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Cpp

Uploaded by

keshavpatel2287
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Include <iostream>

Using namespace std;

Int main() {

Char choice;

Double temperature, convertedTemperature;

// Display available conversion options

Cout << “Temperature Converter” << endl;

Cout << “Select conversion option:” << endl;

Cout << “1. Celsius to Fahrenheit” << endl;

Cout << “2. Fahrenheit to Celsius” << endl;

Cout << “3. Celsius to Kelvin” << endl;

Cout << “4. Kelvin to Celsius” << endl;

Cout << “5. Fahrenheit to Kelvin” << endl;

Cout << “6. Kelvin to Fahrenheit” << endl;

Cin >> choice;

// Input the temperature to convert

Cout << “Enter the temperature: “;

Cin >> temperature;

// Perform the chosen conversion

Switch(choice) {

Case ‘1’:

convertedTemperature = (temperature * 9/5) + 32;

cout << “Result: “ << temperature << “ Celsius = “ << convertedTemperature << “
Fahrenheit” << endl;

break;

case ‘2’:
convertedTemperature = (temperature – 32) * 5/9;

cout << “Result: “ << temperature << “ Fahrenheit = “ << convertedTemperature << “
Celsius” << endl;

break;

case ‘3’:

convertedTemperature = temperature + 273.15;

cout << “Result: “ << temperature << “ Celsius = “ << convertedTemperature << “
Kelvin” << endl;

break;

case ‘4’:

convertedTemperature = temperature – 273.15;

cout << “Result: “ << temperature << “ Kelvin = “ << convertedTemperature << “
Celsius” << endl;

break;

case ‘5’:

convertedTemperature = (temperature – 32) * 5/9 + 273.15;

cout << “Result: “ << temperature << “ Fahrenheit = “ << convertedTemperature << “
Kelvin” << endl;

break;

case ‘6’:

convertedTemperature = (temperature – 273.15) * 9/5 + 32;

cout << “Result: “ << temperature << “ Kelvin = “ << convertedTemperature << “
Fahrenheit” << endl;

break;

default:

cout << “Error: Invalid option!” << endl;

break;
}

Return 0;

You might also like