Pages

Sunday, August 20, 2017

Fahrenheit to Celsius using Class


Program to convert Fahrenheit to Celsius using Class.

#include<iostream>
using namespace std;
class Temperature
{
   float f,c;

   public:
      void  readFahrenheit(){
cout<<"Enter Fahrenheit degree: ";
cin>>f;
     }
      void convertToCelsius(void){
//float v;
c = (f-32)/1.8;
cout<<"Celsius Degree = "<<c;      
      }
};

int  main()
{
Temperature c;
c.readFahrenheit();
c.convertToCelsius();
return 0;
}

Output of program

Enter Fahrenheit degree: 200
Celsius Degree = 93.3333

No comments:

Post a Comment