Search This Blog

Thursday 28 January 2016

Write a C++ program, that will ask a temperature in Fahrenheit and display in Celsius using a class called temp and member functions.

#include<iostream>

using namespace std;

class temp
{
float feren,celc;
public:

void data()
{
cout<<"Enter Temp in fahrenheit:";
cin>>feren;
}

void convert()
{
celc=(0.56)*(feren-32);
cout<<"Temp in celsius is:"<<celc;
}
};

int main()
{
temp t;
t.data();
t.convert();
return 0;
}

No comments:

Post a Comment