answersLogoWhite

0

#include
#include

void main()
{

long n,s=0,t,d;
clrscr();

cout << "Enter a number : ";
cin >> n;

t=n;

while(n>0)
{
d=n%10;
s=s+d;
n=n/10;
}

cout << "Sum of " << t << " is " << s << endl;

getch();
}

User Avatar

Wiki User

15y ago

What else can I help you with?