generate functionThu, 22 Dec 2022

write a function to receive a whole number and return the sum of its digits

public static int SumDigits(int number) { int sum = 0; while (number != 0) { sum += number % 10; number /= 10; } return sum; }

Questions about programming?Chat with your personal AI assistant