Thread: help with output

  1. #16
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    What are you entering for your data?
    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.

  2. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Maybe you need to invert -2682.00000. Like, maybe the answer is 2682.00000.
    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.

  3. #18
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by dwks
    Code:
    "second is %f seconds.\n",time);
    I already told you to change that to %lf.
    With printf, this is unnecessary and in C89 actually undefined behavior.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #19
    Registered User
    Join Date
    Sep 2005
    Posts
    12
    Code:
    grasqyd = yarea - harea;
    Code:
     I made the change but I'm still getting -2682.00000 seconds for an 
    answer.

    here
    in any case if harea is greater than yarea, obviously ur result is going to be negative .
    that is the reason why ur getting answer in negative.
    Last edited by prasath; 09-19-2005 at 05:53 AM.

  5. #20
    Registered User
    Join Date
    Mar 2005
    Posts
    60
    What do I need to change to correct this negative result? I entered %6.2lf in the result but I don't think it will work.

    Code:
     ("The time required to cut the grass at a rate of two square feet a\n" 
      "second is %6.2lf.\n",time);
    To answer the previous question, I enter values such as:

    Code:
    Enter the length of the yard in feet (eg.20):35
    
    Enter the width of the yard in feet (eg.20):20
    
    Enter the length of the house in feet (eg.20):16
    
    Enter the width of the house in feet (eg.20):13

  6. #21
    Registered User
    Join Date
    Sep 2005
    Posts
    12
    Just check which one is greater and find out the difference accordingly.this solves the negative problem

    Code:
    yarea>harea ? (grasqyd = yarea - harea) : (grasqyd = harea - yarea);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  2. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  3. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  4. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  5. Output problems with structures
    By Gkitty in forum C Programming
    Replies: 1
    Last Post: 12-16-2002, 05:27 AM