Thread: Time between Military Hours

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Not to beat a dead horse because Hunter2's solution is more efficient than mine, but my code should work. For example, say we are finding the number of days between May 1st to April 1st which is a difference of 335 days. Ok, day1 would equal 121 and day2 would equal 91. The variable x would start at 121 and increment, when it hits 365 it will revert to zero since 365%365==0. At this point the loop would have executed 244 times thus numdays will equal 244. Now the loop will keep executing 91 more times incrementing numdays 91 more times at which point x will equal day2. So numdays will have a grand total of 244+91=335 which is the correct answer.
    Last edited by PJYelton; 02-28-2005 at 05:30 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time to seconds program
    By Sure in forum C Programming
    Replies: 1
    Last Post: 06-13-2005, 08:08 PM
  2. Killing someones grandparents
    By nickname_changed in forum A Brief History of Cprogramming.com
    Replies: 37
    Last Post: 09-07-2003, 07:56 AM
  3. The Timing is incorret
    By Drew in forum C++ Programming
    Replies: 5
    Last Post: 08-28-2003, 04:57 PM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM