To count the number of times a digit occurs in an integer, start by initializing an array of ten counts of digits, such as int digits[10];
Then, in a loop while the number is non zero, increment the element in the digits array that corresponds to the units digit, and then divide the number by ten, such as digits[number%10]++ and number/=10;
int digits[10];
int i;
int number = some number;
for (i=0; i<10; i++) digits[i]=0;
do (digits[number%10]++; number/=10) while (number != 0);
dvve evd
10
99
No. An integer may not have any non-zero digit after the decimal point.
There is none. The biggest integer is 7-digit.
Function sum_odd_digits(ByVal number As Integer) As Integer Dim digit As Integer sum_odd_digits = 0 While number <> 0 digit = number Mod 10 If digit And 1 Then sum_odd_digits = sum_odd_digits + digit number = number / 10 End While End Function
there could be a part in it like this: int num, digit; int count [10]; do { digit = num%10; num != 10; ++count[digit]; } while (num);
Use an enum if you are using a c style language. Or a map data structure. Assign each integer an English value and then match it to what the user inputs.
1
dvve evd
The smallest three digit integer is 100
The smallest 5 digit integer is -99999. The largest 5 digit integer is 99999. The sum is therefore 0.
A decimal number can be an integer. All that decimal means is that the place value of each digit is ten times that of the digit to its right.
Input the number as a string. If the string has a length of 4 and contains only digits, convert the string to an integer. If the integer is less than 1000, input another number. Otherwise, copy the integer and divide by 100 to get rid of the two least-significant digits. Divide again by 2 and take the remainder. If the remainder is 1 then the second left digit of the 4-digit integer is odd and the 4-digit integer can be added to the array, otherwise do not add it. Repeat for all n numbers.
'Number' or 'digit'.
A six-digit integer.
It is a 29-digit integer. So what?