Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. time counter

time counter

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jroxxxer
    wrote on last edited by
    #1

    I am writing a program where two different times in a day are giving and the program will solve how many hour and how many minutes. For example: input start time input end time output duration or input 5:30 input 6:40 output 1 hour 10 minutes can anybody help me?

    C W 2 Replies Last reply
    0
    • J jroxxxer

      I am writing a program where two different times in a day are giving and the program will solve how many hour and how many minutes. For example: input start time input end time output duration or input 5:30 input 6:40 output 1 hour 10 minutes can anybody help me?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      What have you written so far ?

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      1 Reply Last reply
      0
      • J jroxxxer

        I am writing a program where two different times in a day are giving and the program will solve how many hour and how many minutes. For example: input start time input end time output duration or input 5:30 input 6:40 output 1 hour 10 minutes can anybody help me?

        W Offline
        W Offline
        whatever whatever com
        wrote on last edited by
        #3

        Compare the hour value and use the bigger hour minus the smaller hour, let this be h. If both are the same hour, just subtract the minutes. Next, use the minutes from the "bigger" hour to minus the minutes from the "smaller" hour, let this be m. If the m is negative, subtract 1 from the h, and add 60 to m.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups