Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Need help using C+

  1. Oct 17, 2008 #1
    Hey guys, I need a little bit of help understanding this question and writing the code for it:

    Write the code to count the number of decimal digits (0-9) input from the keyboard until the user presses '\n' and then display this count on the monitor (Declare necessary variables)

    Regarding the decimal digits, do they mean the Hex number for the ASCII character 0-9??? Could you please clarify this for me? Thanks.
  2. jcsd
  3. Oct 17, 2008 #2
    i'm pretty sure they mean the ascii code for characters 0-9. (without looking)i believe all the ascii characters with values 0 through 9 are non-printing and can't be entered from the keyboard without a combination of keypresses (alt codes). whether you look at them as hex is up to you.
  4. Oct 17, 2008 #3


    User Avatar
    Homework Helper

    You need to take in the input as a string, examine each string character individually and write a function to determine if the character examined is 0-9. You know what to do from here, right?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook