the problem no matter what, depth either equals 0, or shows equaling whatever put in scan, stills acts 0 later. tried messing around formatting bit no avail. thanks!
#include <stdio.h> int main(void) { double depth; printf("please enter current depth in kilometers."); scanf("%d", &depth); printf("the depth %f \n", depth); double celcius = (10* depth + 20); printf("the temperature in celcius %f \n", celcius); double fahrenheit = (1.8*celcius+31); printf("the temperature in fahrenheit %f \n", fahrenheit); }
the compiler should warn %d
isn't correct format specifiers double. %lf
correct 1 scanf
, while can use %f
printf
. advice compile 1 (or of them) of command listed above :
- -wall
- -wextra
- -pedantic
you can find more information gcc warnings here.
also have read here :
Comments
Post a Comment