Sum of first and last digit of a number in C++
// not my code but I figured it would be useful
int number, sum=0, firstDigit, lastDigit;
//Reading a number from user
cout<<"Enter any number:";
cin>>number;
lastDigit = number % 10;
firstDigit = number;
while(number >= 10)
{
number = number / 10;
}
firstDigit = number;
//Finding sum of first and last digit
sum = firstDigit + lastDigit;
cout<<"Sum of first and last digit: "<<sum;