Temperature Convertion

hello i have been trying to convert my temperature from fahrenheit to celcius and i am having troubles trying to figure out how to get it to convert. i got the fahrenheit to count but all my celcius does is just states itself as zero. can anyone help. here is my program thus far...


//
//LAB 2: TEMPERATURE CONVERSIONS
//AUTHOR: COULTON GURNEY
//VERSION 1.0 //////////////////////////
//DATE: 02-14-12 // \t to make columns [s]//

// // [/s]//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include<stdio.h>
#include<math.h>

int main()

{ double LF; //lowest Fahrenheit
double HF; //highest Fahrenheit
double F; // temperature in Fahrenheit
double k; //Kelvin = C+273.15
double c; //Celsius =(f-32)*(5/9)
double C;


printf ("lowest temperature in Fahrenheit: ");
scanf_s ("%lf", &LF);

printf ("Highest temperature in Fahrenheit: ");
scanf_s ("%lf", &HF);

for ( F=LF ;F <= HF ; F++)
{
printf("F = %lf \n", F);

}

for ( C = ((LF-32)*(5/9)) ;C <= ((HF-32)*(5/9)) ; C++)

{
printf("C = %lf \t \n", C);
}



fflush(stdin);
getchar();}
Last edited on
The decimal points after the numbers actually let the compiler know that a number is to be treated as a double. If you try to divide the integer 5 by 9, it's going to truncate to 0. 5.0, however...

EDIT: void main() is evil. Could you please change it to the standards-compliant int main()?

-Albatross
Last edited on
Your for loop is messed up.
1
2
3
for ( [initialize counter here] ; [limit counter here] ; [increment counter here] ){
    [convert temperature here];
}
lol Thanks albatross. and my im just starting programming and that is how my book has started off its programs in the book. my teacher has already talked about it and he said we would be using int main() more often in the future.
also is how do i put the celcuis in another column? i put \t but i imagine its probably in the wrong spot. yes?
I think you'd have to merge your two for loops for that, which, if you use ciphermagi's template, shouldn't be that hard to do. ;)

-Albatross
Topic archived. No new replies allowed.