#include <iostream>
using namespace std;

int sumOfDigits(int num){
    int digSum=0;

    while(num>0){
        int lastDig= num % 10;
        num /=10;

        digSum+=lastDig;
    }
    return digSum;
}

int main() {
    cout << sumOfDigits(2345454) << endl;
    
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: