Hello friends, Welcome to your Techgsr.co blog. And today in this article we will learn about How to write program convert temperatures from Celsius to Fahrenheit and vice versa .So let’s go to our topic
#include <iostream.h> #include <conio.h> void main() { clrscr(); int choice; float ctemp,ftemp; cout << “1.Celsius to Fahrenheit” << endl; cout << “2.Fahrenheit to Celsius” << endl; cout << “Choose between 1 & 2 : ” << endl; cin>>choice; if (choice==1) { cout << “Enter the temperature in Celsius : ” << endl; cin>>ctemp; ftemp=(1.8*ctemp)+32; cout << “Temperature in Fahrenheit = ” << ftemp << endl; } else { cout << “Enter the temperature in Fahrenheit : ” << endl; cin>>ftemp; ctemp=(ftemp-32)/1.8; cout << “Temperature in Celsius = ” << ctemp << endl; } getch(); }
This program takes in the user’s choice choice as a screen input from the user.
It then asks the user for a temperature in Celsius or Fahrenheit depending on the choice.
It then converts the Celsius temperature to Fahrenheit or vice versa and prints it out using
the ‘cout’ command.
INPUT :
2
98.6
OUTPUT :
Temperature in Celcius = 37
Related Post:-
So I hope that you learn about the this program And if you have any more queries about progrmming ,web Devlopment ,tech,computer relegated then feel free to discuss your problem in the comment section.Thank you so much and come back for more updates about Techgsr.co .