Sample – Program to convert temperatures from Celsius to Fahrenheit and vice versa.
by Nideesh C on February 8, 2011 · 3 comments
in C++
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int choice;
float ctemp,ftemp;
cout << “1.Celsius to Fahrenheit” << endl;
cout << “2.Fahrenheit to Celsius” << endl;
cout << “Choose between 1 & 2 : ” << endl;
cin>>choice;
if (choice==1)
{
cout << “Enter the temperature in Celsius : ” << endl;
cin>>ctemp;
ftemp=(1.8*ctemp)+32;
cout << “Temperature in Fahrenheit = ” << ftemp << endl;
}
else
{
cout << “Enter the temperature in Fahrenheit : ” << endl;
cin>>ftemp;
ctemp=(ftemp-32)/1.8;
cout << “Temperature in Celsius = ” << ctemp << endl;
}
getch();
}
This program takes in the user’s choice choice as a screen input from the user.
It then asks the user for a temperature in Celsius or Fahrenheit depending on the choice.
It then converts the Celsius temperature to Fahrenheit or vice versa and prints it out using the ‘cout’ command.
Not Satisfied ? Just search & get the result
Related posts:
- Sample – convert temperatures
- Sample – Program to convert days into years and weeks.
- Sample – Program to compute the fibonacci series.
- Sample – Program to enter a letter and output the next 2 letters.
- Sample – Program to find the roots of a quadratic equation.
Tagged as:
c programming examples,
c programming reference,
c tutorial,
c++ program examples,
C++ Programming,
learning c++,
Program to convert temperatures from Celsius to Fahrenheit and vice versa.,
programming languages,
programming languages c,
sample c++ programs
Me, freelance system administrator having the qualification of Diploma in Electronics & Tele-communication + MCSE + CCNA + CST + 5 years of experience in IT field.
If you like This post, you can follow TheOnlineTutorials on Twitter.
Contact me Via email: support@theonlinetutorials.com
Subscribe to feed via Feed or EMAIL to receive instant updates.
Legal Disclaimer:All information found on the site is without any implied warranty of fitness for any purpose or use whatsoever. Content author/site administrator is not responsible for any loss occurred due to mistakes in this tutorial. Use this tutorial website at your own risk.
{ 3 comments… read them below or add one }
I’ve bookmarked your blog.Thanks for the useful information — Program to convert temperatures from Celsius to Fahrenheit and vice versa.
Sample – Program to convert temperatures from Celsius to Fahrenheit and vice versa.
Another great post, amazing! – Program to convert temperatures from Celsius to Fahrenheit and vice versa.