Solution to the problem number 11332 of UVA - 11332.

Any questions do not hesitate to contact.

#include<bits/stdc++.h>
using namespace std;
int res(int n) {
    if(n < 10)	return n;
    int sum = 0;
    while(n) {
        sum += n%10;
        n /= 10;
    }
    return res(sum);
}
int main() {
    int cases;
    while(scanf("%d", &cases) == 1 && cases!=0)
        printf("%d\n", res(cases));
    return 0;
}

Don't miss anything.

Keep in touch with Isaac Lozano Osorio!