Thread: Calculating miles,cals, fat

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    21

    Calculating miles,cals, fat

    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?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    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
    You're calculating the result before you've input the data.
    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.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calculating : high numbers
    By MiraX33 in forum C++ Programming
    Replies: 9
    Last Post: 06-08-2006, 11:08 PM
  2. Recursion
    By Lionmane in forum C Programming
    Replies: 11
    Last Post: 06-04-2005, 12:00 AM
  3. Taking input while calculating
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 07-12-2002, 04:47 PM
  4. How to loop a function
    By Unregistered in forum C Programming
    Replies: 12
    Last Post: 04-14-2002, 12:52 PM
  5. Calculating window sizes
    By Mox in forum Windows Programming
    Replies: 3
    Last Post: 11-08-2001, 09:17 PM

Tags for this Thread