Banner Ad

    A    L    W    A    Y    S           D    E    S    I    R    E           T    O           L    E    A    R    N           S    O    M    E    T    H    I    N    G           U    S    E    F    U    L   

Sunday, May 8, 2011

IPE Lab 9A1

#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);
}
 

0 comments:

Related Posts Plugin for WordPress, Blogger...

your comments