// Arup Guha
// 9/21/2011
// Written in COP 3223 to show how to sum up the digits in
// a number.
#include <stdio.h>

int main() {

    int sumdigits = 0;
    int n;

    // Get a number.
    printf("Enter a number.\n");
    scanf("%d", &n);

    // Initial values for both of these
    int number = n;
    int flip = 0;

    // Peel off each digit.
    while (number > 0) {

        // Adjust the sum and the flipped number.
        sumdigits += (number%10);
        flip = 10*flip + number%10;

        // Clip off the units digit of the number.
        number = number/10;
    }

    // Print out the sum of the digits and its flip.
    printf("Sum of the digits of %d is %d\n", n, sumdigits);
    printf("Its flip is %d\n", flip);

    return 0;
}
