Re: [Dev-C++] calculating Celsius to Fahrenheit
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: ropbert d b. <lon...@ju...> - 2001-01-31 00:37:43
|
Try this. Yout close:
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
float calc(float);
int main()
{
float c, c1;
int fahr, cnt=0;
printf("Fahrenheit: Fahrenheit: \n");
// scanf("%d", &fahr);
for (fahr=0; fahr<=212; fahr++)
{
c = calc(fahr++);
c1 = calc(fahr);
// printf("%2f", 10,3, c, -c);
printf("%10.3f %10.3f \n", c, c1);
if (cnt++ == 21)
{
system("pause");
cnt = 0;
printf("Fahrenheit: Fahrenheit: \n");
}
}
system("PAUSE");
return 0;
}
float calc(float fahr)
{
float cels = 5.0 / 9.0 * (fahr - 32);
return cels;
}
On Tue, 30 Jan 2001 10:05:43 -0500 "Mitchell, Tamra (HNA)"
<Tam...@hj...> writes:
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 |