Radical Developers welcomes all the visitors to be a member of the team. Come join us. Its all about open-source concept. All Programs are written and tested in MacOS X, Unix, Linux and may not match with the outputs of Turbo C++ in Windows

Tuesday, January 4, 2011

Write a C++ Program using class that will ask for a temperature in Fahrenheit and display it in Celsius.




Source Code :

#include<iostream.h>
class con {
      public :
      float f;
      float convert() {
            return (((f-32)/9)*5);
      }
};
int main() {
      float c;
      con ob1;
      cout<<"Enter Temperature in Fahrenheit : ";
      cin>>ob1.f;
      c=ob1.convert();
      cout<<"Temperature in Celsius : "<<c;
      return 0;
}

Output :

Enter Temperature in Fahrenheit : 212
Temperature in Celsius : 100

No comments:

Post a Comment