/* Program Name : Calculate sum of a three digits number
Date: 20-3-2019
Developer: Aditi B*/
#include <iostream>
using namespace std;
int main()
{
int sum, num, count, val;
count = 0;
cout << "Enter a three digit number:\t";
cin >> val;
num = val;
while(num !=0)
{
count ++; // we are adding the number of digits to the variable count
if(count>3) // if no. of digits is greater than 3
{
cout << "Please Enter a three digit number only\n";
break;
}
sum = sum + num % 10;
num = num / 10;
}
cout<<"\n";
cout << "\nThe sum of three digits of given number:" << val << " is " << sum;
cout<<"\n";
return 0;
}