Search
An excellent Converter that you can use to convert the temperatures between Celsius and Fahrenheit
Admin | 8:31 AM |
Programing
How
are you all friends? I hope good
Sometimes we need to change the temperature. Today, I'll share with you a nice program that you can convert the temperatures between Fahrenheit and Celsius by using this code-
#include<iostream>
using namespace std;
int main()
{
double fahrenheit, celsius;
char choice;
cout<<"enter 'cf' for celsius to fahrenheit conversion or 'fc' for fahrenheit to celsius conversion:"<<endl;
cin>>choice;
if(choice='cf')
{
cout<<"enter temperature in celsius:"<<endl;
cin>>celsius;
fahrenheit=(celsius * 1.8) + 32;
cout<<"temperature in fahrenheit is "<<fahrenheit<<" degree fahrenheit"<<endl;
}
else if(choice='fc')
{
cout<<"enter temperature in fahrenheit:"<<endl;
cin>>fahrenheit;
celsius=(fahrenheit - 32) * 5 / 9 ;
cout<<"temperature in celsius is :"<<celsius<< " degree celsius"<<endl;
}
else
{
cout<<"error"<<endl;
exit (1);
}
return 0;
}
Thanks to reading.
Sometimes we need to change the temperature. Today, I'll share with you a nice program that you can convert the temperatures between Fahrenheit and Celsius by using this code-
#include<iostream>
using namespace std;
int main()
{
double fahrenheit, celsius;
char choice;
cout<<"enter 'cf' for celsius to fahrenheit conversion or 'fc' for fahrenheit to celsius conversion:"<<endl;
cin>>choice;
if(choice='cf')
{
cout<<"enter temperature in celsius:"<<endl;
cin>>celsius;
fahrenheit=(celsius * 1.8) + 32;
cout<<"temperature in fahrenheit is "<<fahrenheit<<" degree fahrenheit"<<endl;
}
else if(choice='fc')
{
cout<<"enter temperature in fahrenheit:"<<endl;
cin>>fahrenheit;
celsius=(fahrenheit - 32) * 5 / 9 ;
cout<<"temperature in celsius is :"<<celsius<< " degree celsius"<<endl;
}
else
{
cout<<"error"<<endl;
exit (1);
}
return 0;
}
Thanks to reading.
0 comments:
Post a Comment