View Single Post
  #1  
Old 09-03-2011, 12:20 AM
bonfire's Avatar
bonfire bonfire is offline
M.Arsalan Qureshi

 
Join Date: Oct 2008
Location: Garden Town, Multan Cantt
Posts: 616
Program / Discipline: BSTS
Class Roll Number: 09-31
bonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond reputebonfire has a reputation beyond repute
Default Program to convert temperatures from Celsius to Fahrenheit and vice versa

Program to convert temperatures from Celsius to Fahrenheit and vice versa


#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.

Sample Input


2
98.6
Sample Output

Temperature in Celcius = 37

__________________

Reply With Quote