Help with in Command Line Argument and Multiple Sum Digits

This is a discussion on Help with in Command Line Argument and Multiple Sum Digits within the C++ Programming forums, part of the General Programming Boards category; Hey everybody I'm fairly new to C++ and have been understanding until Ive hit this rock. Im trying to figure ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    Help with in Command Line Argument and Multiple Sum Digits

    Hey everybody I'm fairly new to C++ and have been understanding until Ive hit this rock. Im trying to figure out how to indicate whether or not a first command line argument interpreted as an integer is a multiple of the sum of its own digits. I understand that logic as if you type 20 = 2(2+0) where 2 is a multiple and 3113 = 8 which is not a multiple but i feel hopeless trying to set it up. Any tips, hints or help i would love so much. Thanks anyone for a comment in advance. And here is my code.
    Code:
     
    Code:
    #include <iostream>
    using namespace std;
    
    
    int main(int argc, char*argv[])
    {
    
    int num, rem, sum = 0;
    
    cout << "Enter a number :"<<endl;
    cin >> num;
    
    while(num!=0)
    {
    rem=num%10;
    num=num/10;
    sum=sum+rem;
    }
    
    cout << sum << endl;
    
    return 0;
    }
    

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. command line argument help
    By bobnet in forum C++ Programming
    Replies: 1
    Last Post: 10-11-2003, 12:22 AM
  2. command line argument
    By Lord CyKill in forum Linux Programming
    Replies: 1
    Last Post: 04-11-2003, 02:05 PM
  3. Command line argument
    By Max in forum C Programming
    Replies: 2
    Last Post: 07-17-2002, 02:10 PM
  4. '*' as a command line argument
    By kooma in forum C Programming
    Replies: 6
    Last Post: 02-26-2002, 01:18 PM
  5. Command Line argument
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 10-12-2001, 03:24 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21