1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Clocks! PLEASE HELP!!!

Discussion in 'C' started by mjmjmjmj, Feb 8, 2013.

  1. mjmjmjmj

    mjmjmjmj New Member

    Feb 8, 2013
    Likes Received:
    Trophy Points:
    Time can be stated in 24 hour (Military) format. For example, 5 minutes after one o'clock in the afternoon can be stated as 13:05 hrs. If we include seconds, then 5 minutes and 24 seconds after one o'clock in the afternoon could be stated as 13:05:24 hrs.
    The range for the hour portion of the time is from 00 to 23 while for the minute and second, the range is from 00 to 59.
    Note that 00:00:00 hrs represents midnight while 12:00:00 represents noon.
    Also note that the hour, minute and second are each represented by two digits and are delimited by colons :)).

    For more information on this time format please visit this link.
    •24 hour clock


    Your program prompts for and accepts the following information:
    •the time on the first clock

    •the time on the second clock

    •the operation to perform

    ◦a plus (+) sign means add clock two to clock one giving clock three
    ■Adding clock two to clock one implies moving clock one forward by the amount of time shown on clock two.
    ◦a minus (-) sign means subtract clock two from clock one giving clock three
    ■Subtracting clock two from clock one implies moving clock one backward by the time shown on clock two.

    00:00:00 - 00:00:01 = 23:59:59 01:01:01 - 23:59:59 = 01:01:02 01:01:01 - 00:00:02 = 01:00:59 23:59:59 + 00:00:01 = 00:00:00 01:01:59 + 00:00:01 = 01:02:00 01:01:01 + 23:59:59 = 01:01:00
    You may assume that the user shall input this information correctly.

    Design your program so that it displays clock three, the result of adding or subtracting clocks.

    So far I have:

    main() {

    int hr1, min1, sec1, hr2, min2, sec2, hr3, min3, sec3, input;

    printf("Enter time one, seperated by colons: ");
    scanf("%d:%d%d", &hr1, &min1, &sec1);

    printf("Enter time two, seperated by colons: ");
    scanf("%d:%d:%d", &hr2, min2, sec2);

    printf("Enter 1 to add the two times or enter 2 to subtract the two times: ");
    scanf("%d", &input);


    and thats all i have.
    i would really appreciate any help from anyone asap


Share This Page