Program to convert Fahrenheit to Celsius or Celsius to Fahrenheit || BigFootCODE
Program to convert Fahrenheit to Celsius or Celsius to Fahrenheit
In this simple program of converting Fahrenheit to Celsius or Celsius to Fahrenheit firstly we give a small menu to the user so that he/she can decide what he want to do Fahrenheit to Celsius or Celsius to Fahrenheit and on depending upon the user choice we receive the input using a variable and then perform a function .
after that we allow user to enter the values so that we can process on it and provide a relevant output to the user.
| #include<iostream.h> int main() | |
| {int choice; | |
| float temp,countemp; | |
| cout<<"temperature conversion menu :"; | |
| cout<<"1. fahrenheit to Celsius "<<"\n"; | |
| cout<<"2. Celsius to fahrenhiet "<<"\n"; | |
| cout<<"enter your choice:" ; | |
| cin>>choice ; | |
| if(choice==1) | |
| { cout<<"\n"<<"enter temperature in Fahrenheit :"; | |
| cin>>temp ; | |
| countemp = (temp -32)/1.8 ; | |
| cout<<" the temperature in clesius is :"<<countemp<<"\n"; | |
| }else | |
| { cout<<"\n"<<"enter temperature in centigrade :"; | |
| cin>>temp; | |
| countemp = 1.8*temp + 32 ; | |
| cout<<" the temperature in Fahrenheit is : "<<countemp<<"\n"; | |
| } | |
| return 0 ; | |
}
Other related questions:- |


0 Comments
if you have any doubt let me know in comment