answersLogoWhite

0


Best Answer

To do this manually, you can simply read through the number, keeping a manual tally in your head.

If you are looking for an algorithm to do it for you, here is one method that would work in C, where "number" is the value being tested and "digit" is the digit we're counting:

...

int whole = (int)number;

number -= whole;

tally = 0;

while(whole != 0){

if(whole % 10 digit) tally++;

number -= (int)number;

}

printf("We counted %i digits occurrences of the digit %i\n", tally, digit);

...

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Find the number of occurrences of a digit in a number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Find the diagonal mentod of two digit and three digit number?

find the diagonal method of two digit number and three digit number


What single digit appears most frequently between and including the numbers 1 and 1,000 Hint: look for a pattern?

The single-digit that appears most frequently between and including the numbers 1 and 1000 is the digit "1". To see why this is the case, consider the following pattern: Between 1 and 9, there is one occurrence of the digit "1". Between 10 and 99, there are 10 occurrences of the digit "1" in the tens place (10, 11, 12, ..., 19) and 9 occurrences of the digit "1" in the ones place (21, 31, 41, ..., 91), for a total of 19 occurrences. Between 100 and 999, there are 100 occurrences of the digit "1" in the hundreds place (100, 101, 102, ..., 199), 100 occurrences of the digit "1" in the tens place (110, 111, 112, ..., 119, 121, 131, ..., 191, 201, ..., 291, 301, ..., 391, ..., 901, ..., 991) and 9 occurrences of the digit "1" in the ones place (101, 111, 121, ..., 191), for a total of 210 occurrences. Adding up the number of occurrences for each range, we get: 1 + 19 + 210 = 230 Therefore, the digit "1"


How do you Write a program that determines the number of occurrences of each digit in a given integer n?

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);


If the units digit and the hundreds digit of the number 513 were reversed find the sum of the original number and the new number?

"If the units digit and the hundreds digit of the number 513 were reversed..." 315 'find the sum of the original number and the new number." 513+315=828


How do you find estimated digits in a number?

The last digit is always the estimated digit in a number


How do you find the position of the first digit of a quotient?

first you look at the first number tell what that number is then you just find the first digit.


The unit digit number is 3 and seven times the sum of the digit is the number itself Find the number?

It is 63.


Find the difference between the largest 8 digit number and the smallest 6 digit number?

It is 99,899,999.


The units digit of a two digit number exceeds twice the tens digit by 1 what numbers if the sum of its digit is 10?

The units digit of a two digit number exceeds twice the tens digit by 1. Find the number if the sum of its digits is 10.


The sum of digits of a two-digit number if five Find the number if the ten's digit is five more than the one's digit?

50


How many 5 are in 450000?

90000 5's are in 450000.


How do you call the US if you have only 9 digit phone number?

You are missing a digit. Find it.