Thread: Problem with string integer value

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    4

    Problem with string integer value

    Code:
    Prompt the user to input a string, 
    and then output the sum of all the digits in the string.
    
    
    Sample Run 1:
    
       Input -> A111B222C
       output -> 9
    
    
    Sample Run 2:
    
    
       Input -> ABC123XYZ32100000005555555555zzzzzz
      output -> 62
    Do anyone got idea on how to doing this?

    Thanks.
    Last edited by yongsheng94; 08-14-2013 at 10:38 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Announcements - C++ Programming
    The only problem is your lack of effort.

    You can't just dump your assignment and wait, you have to show us how far you got.

    At the very least, you should be able to handle the "Q&A" part of the problem, before you get to the calculation.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get integer from string???
    By cprogbiginner in forum C Programming
    Replies: 5
    Last Post: 05-11-2012, 04:43 AM
  2. Convert Integer to String and String to Integer
    By hqt in forum C++ Programming
    Replies: 26
    Last Post: 09-15-2011, 11:39 AM
  3. Replies: 4
    Last Post: 12-04-2009, 10:22 AM
  4. Put an integer in a string?
    By guitarist809 in forum C++ Programming
    Replies: 1
    Last Post: 04-18-2008, 12:24 PM
  5. hex string to integer...
    By Ruchikar in forum C Programming
    Replies: 3
    Last Post: 10-16-2002, 06:58 AM

Tags for this Thread