Calculati suma cifrelor unui numar x citit de la tastatura

#include<iostream.h>
void main()
{
int s;
long d,x;
cout<<"x=";cin>>x;
d=x;
s=0;
while(d)
{
s=s+d%10;
d=d/10;
}
cout<<"s="<<s;
}

{joscommentenable}