question about double and float
Hi fellow programmers,
I am new to programming and working on learning C. I have am confused about the following. I tried to program celsius to fahrenheit converter. If i use float for celsius and fahrenheit, it works. but if i use those two variables as double then it only shows 32 as an answer. Is there something i neeed to know about doubles?? Here is the program.
Code:
#include <stdio.h>
main(){
double celsius;
double fahrenheit;
printf("Enter temperature in Celsius: ");
scanf("%f", &celsius);
fahrenheit = 32 + celsius * 9.0 / 5.0;
printf("The temperature in Fahrenheit is %.2f" , fahrenheit);
fflush(stdin);
getchar();
}
Thanks guys!