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 Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – convert temperatures
  2. Sample – Program to convert days into years and weeks.
  3. Sample – Program to compute the fibonacci series.
  4. Sample – Program to enter a letter and output the next 2 letters.
  5. Sample – Program to find the roots of a quadratic equation.

{ 3 comments… read them below or add one }

1 Dues February 11, 2011 at 5:38 am

I’ve bookmarked your blog.Thanks for the useful information — Program to convert temperatures from Celsius to Fahrenheit and vice versa.

Reply

2 Kaos Murah April 23, 2011 at 2:56 am

Sample – Program to convert temperatures from Celsius to Fahrenheit and vice versa.

Reply

3 Vinila April 24, 2011 at 3:00 am

Another great post, amazing! – Program to convert temperatures from Celsius to Fahrenheit and vice versa.

Reply

Leave a Comment

Previous post:

Next post: