Thread: Where do I begin with this program...elapsed time function?

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    42

    Where do I begin with this program...elapsed time function?

    Write a complete program with the elapsed_time function. Use the following data as test vectors:

    Time1 = 3:45:15 and Time2 = 9:44:03

    Time2 = 11:45:0 and Time2 = 0:0:1


    I don't have to worry about AM/PM, it is military time.............

    need a kickstart. thanks.

  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
    So what is the problem?

    Start with a program which just reads ONE time, and prints it back out.

    Like
    Enter time -> 3:45:15
    You entered 03:45:15
    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
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Sit down and think about it rationally, in small steps... EXACTLY what do you have to do to make that happen?

    Salem has you started down that road... but I would suggest you start the habit of thinking before coding, cultivate it so that it becomes a habit...

    Like my signature says ... 4 steps ...

    Analyse -- understand the problem, exactly what is required of your code.
    Plan -- work out a step by step plan for your solution to the problem.
    Write -- working from your plan, write your code.
    Test -- test each small step as you build the program, then test the program as a whole.

    Note that you don't actually go to the keyboard until the third step...

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    42

    Haha

    Ok thanks guys, I'll be back though because I'm a beginner.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Dom View Post
    Ok thanks guys, I'll be back though because I'm a beginner.
    Of course you will. We're trying to encourage a logical approach here...

    The old saying goes: "Put brain in gear before putting fingers in motion".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time elapsed
    By TitoMB345 in forum C Programming
    Replies: 13
    Last Post: 11-15-2007, 01:50 AM
  2. elapsed time testing
    By deian in forum C Programming
    Replies: 3
    Last Post: 10-12-2004, 09:29 PM
  3. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM
  4. calculate elapsed-time
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 11-26-2001, 07:42 AM