I need to find all possible sums of all digits of integer. Input: 234
Output: 36
Explanation: (2+3+2+4)+(3+2+3+4)+(4+2+4+3)
But I only know how to find the sum of the firs and last digit:
int num, sum = 0, firstDigit, lastDigit;
Console.Write("Enter any number: ");
num = Convert.ToInt32(Console.ReadLine());
lastDigit = num % 10;
firstDigit = num;
while (num >= 10)
{
num = num / 10;
}
firstDigit = num;
sum = firstDigit + lastDigit;
Console.WriteLine("Sum of first and last digit: " + sum);
Console.ReadLine();