-->

Facebook

Jasper Roberts - Blog

Wednesday, March 11, 2015

Write a C++ Program to convert temperature into Fahrenheit.

#include<iostream.h>
//using namespace std;
class Temp
{
float c,f;
public:
void get_temp(void);
void convert(void);
void display(void);
};
void Temp::get_temp(void)
{
cout<<"\nEnter the temparature : ";
cin>>c;
};
void Temp::convert(void)
{
f=(c-32)/9.8;
};
void Temp::display(void)
{
cout<<"Temparature in F = "<<f;
};
void main()
{
Temp t;
t.get_temp();
t.convert();
t.display();
}


RELATED TOPICS
Write a C++ Program to demonstrate class.
Write a C++ Program to demonstrate scope resolution operator.

Write a C++ Program to demonstrate class.

#include<iostream.h>
//using namespace std;
class Abc
{
int a,b,c,x;
public:
void get_data(void);
void count(void);
void display(void);
};
void Abc::get_data(void)
{
cout<<"\nEnter the value of a = ";
cin>>a;
cout<<"\nEnter the value of b = ";
cin>>b;
cout<<"\nEnter the value of c = ";
cin>>c;
};
void Abc::count(void)
{
x=a/(b-c);
};
void Abc::display(void)
{
cout<<"\n x = "<<x;
};
void main()
{
Abc a;
a.get_data();
a.count();
a.display();
}

RELATED TOPICS
Write a C++ Program to convert temperature into Fahrenheit.
Write a C++ Program to demonstrate scope resolution operator.

Write a C++ Program to demonstrate scope resolution operator.

#include<iostream.h>
//using namespace std;
int m=10;
int main()
{
int m=20;
{
int k=m;
int m=30;
cout<<"\nWe are in iner block"<<"\n";
cout<<"\nk = "<<k;
cout<<"\nm = "<<::m;
}
cout<<"We are in outer block"<<"\n";
cout<<"\nm = "<<m;
return 0;
}

RELATED TOPICS
Write a C++ Program to convert temperature into Fahrenheit.
Write a C++ Program to demonstrate class.