Given a number N and a digit D. Write a program to find how many times the digit D appears in the number N.
Input: N = 1122322 , D = 2 Output: 4 Input: N = 346488 , D = 9 Output: 0
The idea to solve this problem is to keep extracting digits from the number N and check the extracted digits with the given digit D. If the extracted digit is equals to the digit D then increment the count.
Below is the implementation of above approach.
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Find the remainder when First digit of a number is divided by its Last digit
- Perform n steps to convert every digit of a number in the format [count][digit]
- Find frequency of smallest value in an array
- Find the element having different frequency than other array elements
- Check if the frequency of all the digits in a number is same
- Count the number of occurrences of a particular digit in a number
- Program to find the last digit of X in base Y
- Special two digit number
- Program to delete Nth digit of a Number
- Check if the first and last digit of number N is prime and their sum is less than K
- Largest K digit number divisible by X
- Largest and smallest digit of a number
- Print multiples of Unit Digit of Given Number
- C++ Program for Smallest K digit number divisible by X
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.