Dev C++ Temperature Conversion

Posted By admin On 19.04.20
Dev C++ Temperature Conversion Average ratng: 5,5/10 9681 votes
Simple C++ program to convert temperature from either Fahrenheit to Celsius or vise-versa.

Simple C program to convert temperature from either Fahrenheit to Celsius or vise-versa. tempCon.cpp. C Program for temperature conversion which converts fahrenheit to celcius or celcius to fahrenheit depending upon user's choice. Void main. Clrscr; //to clear the screen. Float temp,res; int choice. °C, the Celsius Scale (part of the Metric System, used in most countries) °F, the Fahrenheit Scale (used in the US), and They both measure the same thing (temperature!), but use different numbers.

tempCon.cpp

Temperature conversions are performed by using a formula, which differs depending on the two temperature scales you are converting between. For example, to convert 50 degrees Celsius (centigrade) to Fahrenheit, we plug our numbers into the formula as. As a physics persons. You may find that -500 is too low a value (you can not cool things to that temperature ( 0 Kelvin is the lowest temperature theoretically (though there have been experiments that show a temperature a few fractions below this but that has more to do with how we measure the temperature and people are still arguing about it))).

/*******************************************************************
* C++ program to convert temperature from either Fahrenheit to *
* Celsius or vise-versa. *
* *
*******************************************************************/
#include<iostream>
#include<cctype>
usingnamespacestd;
intmain()
{
int temp, tempCon;
char unit;
cout << 'Please enter the temperature and measurement system (c or f): ';
cin >> temp;
cin >> unit;
if ( isupper(unit) )
{
unit = tolower(unit);
}
if (unit 'f')
{
temp = (temp - 32) / 9.0 * 5.0;
cout << temp << ' degrees Celsiusn';
}
elseif (unit 'c')
{
temp = 9.0 / 5.0 * temp + 32;
cout << temp << ' degrees Fahrenheitn';
}
else
{
cout << 'Sorry that unit of measure isn't recognized around here.n';
}
return0;
}

commented Mar 13, 2016

What is the line by line explanation of the above code please

commented Mar 3, 2017

gumagana po ba nyan ?

commented Mar 7, 2019

Dev C++ Temperature Conversion Chart

:(

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Dev C++ Temperature Conversion Calculator

Hi all, Just wondering if you could help me out here. bought a copy of c++ for dummies today and the first program in the book converts fahrenheit to celsius. Now I have some C and Java experience (I am a recent graduate of a software design degree) but have not touched C++ before. Iphone restore tool download. I have modified the conversion program from the c++ for dummies book so that it has a user interface and is capable of converting celsius to fahrenheit. The problem is, after a conversion is made, it reverts back to the main menu (expected), but displays it twice (unexpected). I presume the issue is that there is input left in the stream but cannot find out how to clear it so that the menu is only displayed once, not twice. Any help would be greatly appreciated.

  • 3 Contributors
  • forum 4 Replies
  • 130 Views
  • 8 Hours Discussion Span
  • commentLatest Postby iamthweeLatest Post

Ancient Dragon5,243

First, the program you posted is a bastardization of C and C++ languages. As for your problem you need to flush the 'n' (Enter key) from the keyboard buffer after the sscanf(). There are several ways to do that but in C the easiest is to call getc() to remove the 'n'.