So I made a function that when I put in a set of integers it will display its result example (1234 = 10) but I wasn't allowed to do it with using recursion,
I'm just kind of lost on how to do it without recursion its probably simple but I cant see it.
This is my original code I'm using C++:
#include <iostream>
using namespace std;
int sumofdigits(int n) {
    if (n < 10) return n;
    return n % 10 + sumofdigits(n / 10);
}
int main() {
    int number;
    while (true) {
        cout << "Please, enter numbers (0 to exit): ";
        cin >> number;
        if (!number) break;
        cout << "your result is " << sumofdigits(number) << endl;
    }
    return 0;
}
 
     
     
    