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
- Find the middle digit of a 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
- Count the number of occurrences of a particular digit in a number
- Find last digit in factorial
- Find the largest N digit multiple of N
- Program to find the last digit of X in base Y
- Special two digit number
- Place Value of a given digit in a number
- Largest K digit number divisible by X
- Program to delete Nth digit of a Number
- Largest and smallest digit of a number
- Check if the first and last digit of number N is prime and their sum is less than K
- C++ Program for Largest K digit number divisible by X
- C++ Program for Smallest K digit number divisible by X
- Print multiples of Unit Digit of Given Number
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.