Hi, Don't use so many loops unnecessarly, here is the one way to get your answer in optimistic way. int main() { long num,num1,i=0,sum=0; short remainder = 0; cout<<"Enter the number:"; cin>>num; num1=num; while(num!=0) { remainder = num % 10; num = num / 10; sum = sum + remainder; i++; } cout<<"The sum of the digits of the "<