// Oldham, Jeffrey D. // 1999 Sep 09 // CS1320 // Typed by Justin Bronn for CS1320-5. // This program sums the decimal digits of an integer typed by the // user. #include int main() { int x,q,r; int sum=0; cout << "Please enter an integer: "; cin>>x; while (x!=0) { q=x/10; r=x%10; sum=sum+r; x=q; } cout << "The sum is " << sum << ".\n"; return 0; }