#include <iostream>
using namespace std;
float CelToFar(float cel);
float FarToCel(float far);
int main()
{
int c;
float cel, far;
cout << "\n\nIf you want Celcius from Farenheit, type '1'" << endl
<< "Or if you want Farenheit from Celcius, type '2'" << endl
<< "Enter your choice : ";
cin >> c;
while (c<1 || c>2)
{
cout << "\nPlease enter 1 or 2\nEnter your choice : ";
cin >> c;
}
if(c==1)
{
cout << "\nEnter Temperature in Farenheit : ";
cin >> far;
cel = FarToCel(far);
cout << far << " Farenheits s " << cel << " Celcius\n\n" << endl;
}
else
{
cout << "\nEnter Temperature in Celcius : ";
cin >> cel;
far = CelToFar(cel);
cout << cel << " Celcius is " << far << " Farenheits\n\n" << endl;
}
return 0;
}
float CelToFar(float cel)
{
return cel*(9/5.0f)+32;
}
float FarToCel(float far)
{
return (far-32)*(5.0f/9);
}
using namespace std;
float CelToFar(float cel);
float FarToCel(float far);
int main()
{
int c;
float cel, far;
cout << "\n\nIf you want Celcius from Farenheit, type '1'" << endl
<< "Or if you want Farenheit from Celcius, type '2'" << endl
<< "Enter your choice : ";
cin >> c;
while (c<1 || c>2)
{
cout << "\nPlease enter 1 or 2\nEnter your choice : ";
cin >> c;
}
if(c==1)
{
cout << "\nEnter Temperature in Farenheit : ";
cin >> far;
cel = FarToCel(far);
cout << far << " Farenheits s " << cel << " Celcius\n\n" << endl;
}
else
{
cout << "\nEnter Temperature in Celcius : ";
cin >> cel;
far = CelToFar(cel);
cout << cel << " Celcius is " << far << " Farenheits\n\n" << endl;
}
return 0;
}
float CelToFar(float cel)
{
return cel*(9/5.0f)+32;
}
float FarToCel(float far)
{
return (far-32)*(5.0f/9);
}
0 comments:
Post a Comment