I have problem on the last line where i need to print 2 values - grams_of_fat and pounds.
What am i doing wrong since pounds are not printing out?
I have problem on the last line where i need to print 2 values - grams_of_fat and pounds.
What am i doing wrong since pounds are not printing out?
You're calculating the result before you've input the data.Code:$ gcc -W -Wall -ansi -pedantic -O2 foo.c foo.c: In function `main': foo.c:21: warning: ISO C90 does not support the `%lf' printf format foo.c:23: warning: ISO C90 does not support the `%lf' printf format foo.c:26: warning: ISO C90 does not support the `%lf' printf format foo.c:26: warning: ISO C90 does not support the `%lf' printf format foo.c:29: warning: implicit declaration of function `system' foo.c:8: warning: 'grams_of_fat' might be used uninitialized in this function
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
system() is in stdlib.h.
Also, printf()'s %f handles both doubles and floats. You only need %lf when scanf()'ing doubles.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.