//
// Created by Fredrick Park on 2/7/17.
//

// digitSum program
// sums the digits of an integer that is entered

#include <iostream>
using namespace std;

int main() {
    float sum = 0;
    int N, n, r;
    cout << "Please enter an integer: ";
    cin >> N;
    n = N;
    while(n != 0) {
        r = n % 10;
        sum += r;
        n += -r;
        n /= 10;
    }
    cout << "The sum of the digits of " << N << " is = " << sum << endl;
    return 0;
}