#include <iostream>
using namespace std;

int main() {
    int n;
    cout<<" enter a number :"<<endl;
    cin>>n;

    int sum;
    sum = 0;

    int ld;
    
    while( n!=0)
        {
            ld = n%10;
      
    sum = sum + ld;

    n=n/10;
            
        }
    
    
    cout<<sum<<endl;
}

Embed on website

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