This is a discussion on Logical! Logical! Why do you have to be so Logical? within the C Programming forums, part of the General Programming Boards category; Originally Posted by rags_to_riches Shouldn't there be some sort of subtraction involved in your algorithm there? That would help :-)...
Let me give you a little hint on a different way to do this...
Can you think of a way to use this with what you're trying to do?Code:#define SecInMin = 60 #define SecInHr = SecInMin * 60 #define SecInDay = SecInHr * 24
You might want to review my suggestion in post #7. To find out the number of hours when given the total number of seconds, make use of the number of seconds in an hour. The same idea applies to find out the number of minutes.Originally Posted by g8ortech14
In fact, I suspect that CommonTater has the same idea that I have in mind. So, make use of CommonTater's hint in post #17, but be aware that the code snippet provided has errors of a rather common variety (but that gives you a chance to fix them, which is good practice ).
You wanna tell me what is wrong with my 3 #define statements?
Really... how much COULD be wrong with it?
i dunno, maybe using assignment operators?
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
be:Code:#define SecInMin = 60 #define SecInHr = SecInMin * 60 #define SecInDay = SecInHr * 24
??Code:#define SecInMin 60 #define SecInHr SecInMin * 60 #define SecInDay SecInHr * 24
hey thanks for the practice! I needed that. :-)
rogster001, I was laughing so hard at:
that I did not notice your post. I hate wasting my PostCounts"You wanna tell me what is wrong with my 3 #define statements?
Really... how much COULD be wrong with it?"
on things like this.
Last edited by Char*Pntr; 09-18-2010 at 10:51 AM.
The practice was not for you thoughOriginally Posted by Char*Pntr
In order to avoid potential problems with grouping, and making use of a common convention of fully capitalising macro names, they should actually be:
though it seems that SEC_IN_DAY is not needed here.Code:#define SEC_IN_MIN 60 #define SEC_IN_HR (SEC_IN_MIN * 60) #define SEC_IN_DAY (SEC_IN_HR * 24)
Me tooOriginally Posted by Adak
Hi all I figured it out late Saturday, and have been busy with family and school since then. Thank you so much for the input. Laserlight you helped me without giving me the answer. There were a few others that gave me some direction as well. I figured out that I was making my if/else statements to complex. I think at one point while testing I like 6 if/else statements. All I need is 2 and that resolved it. I actually enjoyed the process of figuring out the answer. i'm happy to share what I came up with, but don't want to post the answer in case another student comes here looking for the answer. Anyway thanks again.
You don't need to use 'double' for hours, mins, seconds. Integer should be fine. Change printf()ís formatting appropriately.