Preview:
#include<iostream>

using namespace std;

int main()

{

int a, sum=0,n;

cin>>a;

while(a!=0){

n=a%10;

sum+=n;

a=a/10;

}

cout<< sum<<endl;

}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter