re
* Write a C++ Program to design a class Temperature
with two float variables fahren and celsius
and a member function 'conversion' to convert
fahrenheit into celsius
*/
#include
using namespace std;
// define a class Temperature
class Temperature
{
private:
float fahren, celsius;
public:
float conversion(float f)
{
fahren=f;
celsius=(fahren-32)* 5.0/9.0;
return celsius;
}
};
int main()
{
// define an object of Temperature class
Temperature t;
float f;
cout<<"Enter Temperature in Fahrenheit=";
cin>>f;
// call conversion function with object t
cout<<"Temperature in Celsius="<
Comments
Post a Comment