Вы не указали, какой язык вы используете, поэтому я отвечаю вам, полагая, что вы кодируете в java.
Для того, чтобы сделать то, что вы просили, вы должны сделать это:
int number = 454685; // = an example number
int[] arr = new int [6]; // array of int, 6 = digits of the number
int i = 0; // counter
while (number > 0) {
arr[i] = number % 10; //stores in arr[i] the last digit
i++; //increment counter
number = number/10; //divides the number per 10 to cancel the last digit (already stored in arr[i])
}
int sum = 0; //declares the sum variable
i = 0; //reset counter
do{
sum = sum + arr[i];
i++;
}while(i < arr.length); //this loop calculates the sum
System.out.println(sum); //prints the sum of the digits
Здесь вы.
Вы имеете в виду «количество 10-значных цифр», да? Если да, это значение 'int', вы не можете хранить отдельные цифры в массиве напрямую. – Federico