#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Training task question


    Hello :)
    I'm a new C student and i got a problem with one of my training tasks.
    I need to make simple code that will check in a number like 10 - 11 - 12 - 13 - 14 - 15 and so on until 99.
    I need to check if the first number is smaller than the second. Like 15. I need to check that 1 is smaller than 5.
    Forgive my spelling or lack of words English is not my home language.
    Thanks in advance!

    ~Dan~
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,110
    Rep Power
    1803
    What exactly is your question? Surely you don't expect someone to do the work for you? Show what you have so far.

    It can be done arithmetically (by treating the input as a number) or by character comparison (by treating the input as a string of characters).

    Mathematically, you can compare the integer division of the number by 10 with the modulo 10 (remainder of division by 10) of the number.

    By character code comparison, you simply compare the first character to the second.

    Comments on this post

    • zedeneye1 disagrees : very good advice.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    of course I did not expected a solution. I had no idea how to handle it and you helped a lot :D thank you!

IMN logo majestic logo threadwatch logo seochat tools logo