Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: URGENT assistance in C Programming

  1. #1
    jclarke's Avatar
    jclarke is offline Programmer
    Join Date
    Feb 2008
    Location
    Australia
    Posts
    104
    Rep Power
    15

    URGENT assistance in C Programming

    Hello again - I know I have returned once again, been busy with uni stuff lately.

    Now, just need some assistance on this one which I am not sure how to put it this way in C programming under linux - anyone help?

    You have a clock with 4 buttons, H+, H-, M+, M-. The two H buttons change hours without affecting the minutes, while the two M buttons change the minutes without affecting the hours.

    H+ increases hours by 1. If hours was 23, pressing H+ sets hours to 00.
    H- decreases hours by 1. If hours was 00, pressing H- sets hours to 23.
    M+ increases minutes by 1. If minutes was 59, pressing M+ sets minutes to 00.
    M- decreases minutes by 1, If minutes was 00, pressing M- sets minutes to 59.

    Write a C prgram which will read two times and determine the smallest number of button presses to change the setting from the first time to second time.

    There will be two lines of input, each containing a time, the hours followed by the minutes.

    The output will be a single number.

    Example:

    Input: 1755

    Output: 2

    Limit: The hours will be in the range [0...23] and the minutes in the range [0...59]

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: URGENT assistance in C Programming

    We don't write your homework for you, but we'll gladly help you. Why don't you write down the steps you would take to do it manually, and then work from there? Post what you've got once you're done with the manual part so I can point you in the right direction.
    sudo rm -rf /

  4. #3
    jclarke's Avatar
    jclarke is offline Programmer
    Join Date
    Feb 2008
    Location
    Australia
    Posts
    104
    Rep Power
    15

    Re: URGENT assistance in C Programming

    Thats OK, I will get the code attempt tomorrow night, and see what happens from there..

    it is pretty late down here right now (Im in Australia)

  5. #4
    cdg10620's Avatar
    cdg10620 is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Texas
    Posts
    387
    Blog Entries
    3
    Rep Power
    12

    Re: URGENT assistance in C Programming

    Code:
    While( !User.hasAnswer )
    {
         User.askQuestion();
    
         if( User.postCode && User.putForthEffort )
         {
              CodeCallMembers.Help();
              User.hasAnswer = true;
         }
         else
         {
              CodeCallMembers.Laugh();
         }
    }
    -CDG10620
    Software Developer

  6. #5
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: URGENT assistance in C Programming

    Just because I'm an insufferable ****, I would amend your if clause to:
    Code:
    if( User.question.type ==  Question::Homework )
    {
        <original if clause here>
    }
    else if( User.question.type == Question::ExpandKnowledge )
        CodeCallMembers.Help();
    else
        CodeCallModerator.delete(User.question);
    sudo rm -rf /

  7. #6
    cdg10620's Avatar
    cdg10620 is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Texas
    Posts
    387
    Blog Entries
    3
    Rep Power
    12

    Re: URGENT assistance in C Programming

    That's a good point. I won't argue with that. I just felt that the Question::Fun would not apply to someone who is obviously lazy and wants us to do homework for them. Typically they post the question, WingedPanther or someone else says "Wow this looks like homework" and then the person admits is a homework assignment or a project.
    -CDG10620
    Software Developer

  8. #7
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: URGENT assistance in C Programming

    Quote Originally Posted by cdg10620 View Post
    I just felt that the Question::Fun would not apply to someone who is obviously lazy and wants us to do homework for them.
    Hence the else if clause. Or am I completely missing something here?
    sudo rm -rf /

  9. #8
    cdg10620's Avatar
    cdg10620 is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Texas
    Posts
    387
    Blog Entries
    3
    Rep Power
    12

    Re: URGENT assistance in C Programming

    I understand what you're saying. Maybe we'll have to add that in.

    Code:
    While( !User.hasAnswer )
    {
       User.askQuestion();
         
       if( User.question.type ==  Question::Homework )
       {
          if( User.postCode && User.putForthEffort )
          {
             CodeCallMembers.Help();
             User.hasAnswer = true;
          }
          else
          {
             CodeCallMembers.Laugh();
          }
       }
       else if( User.question.type == Question::ExpandKnowledge )
          CodeCallMembers.Help();
       else
          CodeCallModerator.delete(User.question);    
    }
    Last edited by cdg10620; 03-25-2010 at 11:50 AM. Reason: Fixed crappy formatting. :)
    -CDG10620
    Software Developer

  10. #9
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: URGENT assistance in C Programming

    Oooh, terrible formatting.
    sudo rm -rf /

  11. #10
    cdg10620's Avatar
    cdg10620 is offline Programming Expert
    Join Date
    Jun 2009
    Location
    Texas
    Posts
    387
    Blog Entries
    3
    Rep Power
    12

    Re: URGENT assistance in C Programming

    better?
    -CDG10620
    Software Developer

Closed Thread
Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. need urgent assistance
    By elizabethmwashuma in forum C# Programming
    Replies: 6
    Last Post: 06-25-2010, 03:24 AM
  2. urgent java programming help!
    By bleedy3 in forum Java Help
    Replies: 4
    Last Post: 01-26-2010, 07:13 PM
  3. Programming Assignment Help- Urgent
    By MythKissbrownie in forum C and C++
    Replies: 6
    Last Post: 09-20-2009, 06:37 PM
  4. Assistance with simple c++ programming assignment
    By genevish in forum C and C++
    Replies: 1
    Last Post: 11-07-2007, 07:13 PM
  5. Programming Assistance for a Newbie?
    By Blind Dragon in forum General Programming
    Replies: 1
    Last Post: 04-20-2007, 06:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts