// Sum of digits.cpp : Defines the entry point for the console application.
#include <iostream>
usingnamespace std;
int main()
{
int num, x, sum=0;
cout<<"Insert an integer between 0 and 1000: ";
cin>>num;
if(num<1 || num>999)
cout<<"Invalid input. Please insert an integer between 0 and 1000"<<endl;
else
{
while (num >0 && num<1000)
{
x = num % 10;
sum = sum + x;
num = num / 10;
}
cout<<"The sum of all the digits is "<<sum<<endl;
}
return 0;
}