[Dev-C++] calculating Celsius to Fahrenheit
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Mitchell, T. (HNA) <Tam...@hj...> - 2001-01-30 15:12:09
|
I am attempting to write a program the convert integer Fahrenheit
temperature from 0 to 212 degrees to floating point Celsius temperature with
3 digits of precision.
The output should be in two right-justified columns of 10 characters each
and the Celsius temp should be preceded by a sign for positive and negative.
Any suggestions.
/* Tamra Mitchell */
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
float calc(float);
int main()
{
float c, f;
int fahr;
printf("Enter Fahrenheit temperature: \n");
scanf("%d", &fahr);
for (f=0; f<=212; f++)
{
c = calc(fahr);
printf("%2f", 10,3, c, -c);
}
system("PAUSE");
return 0;
}
float calc(float fahr)
{
float cels = 5.0 / 9.0 * (fahr - 32);
return cels;
}
Tamra Y. Mitchell
Heinz North America
Operating Systems Analyst
(412) 237-5232 Work
(412) 996-9078 Cell Phone
|