dev c++ - C programming elementary problem -
#include <stdio.h> #include <math.h> int main (void) { float inches; printf("enter number of inches\n"); scanf("%f\n",&inches); float feet; float cm; float yards; float meter; feet = 12 * inches; cm = 2.54 * inches; yards = 36 * inches; meter = 39.37 * inches; printf("amount in feet: %f\n", &feet); printf("amount in cm: %f\n", &cm); printf("amount in yards: %f\n", &yards); printf("amount in meters: %f\n", &meter); getchar(); return 0; } i'm using dev c++
is problem i'm problem i'm working on in c. enter in number in inches print amount in cm,yards,meters , feet. giving me 0.0000 or of them or time up. can't keep screen , thought purpose of getchar() must have been mistaken. great. thanks!
edit 1
what far keeping dev c++ on screen instead of closing out after put stuff in? having put 2 values in before returns in when screen pops up? why??
two problems:
- the usual problem using
scanf(), in leaves newline after number unread , following read operation (thegetchar()here) reads it. - you shouldn't pass pointers
printf(), actual values.
Comments
Post a Comment