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
- 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
- Special two digit number
- Largest K digit number divisible by X
- Program to delete Nth digit of a Number
- 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
- C++ Program for Largest K digit number divisible by X
- Check if the product of digit sum and its reverse equals the number or not
- Given number of matches played, find number of teams in tournament
- Find the number of ways to divide number into four parts such that a = c and b = d
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.