i entered this simple code from a book and its not working.
Code:#include <stdio.h> #include <math.h> void main() { char input[20]; double miles, kilometers; printf("Enter a value in miles:\n"); miles=atof(gets(input)); kilometers = miles*1.609; printf("%.2f miles works out to %.2f kilometers", miles, kilometers); }
its multiplying correctly and everything but it reads the wrong thing. ill put in a number of miles and it always comes out to 37813992.
and this is off topic but what is the point of double variables?