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.
- Find the remainder when First digit of a number is divided by its Last digit
- Find the middle digit of a given Number
- Find frequency of smallest value in an array
- Count the number of occurrences of a particular digit in a number
- Check if the frequency of all the digits in a number is same
- Program to find the last digit of X in base Y
- Find last digit in factorial
- Find the largest N digit multiple of N
- Find two numbers whose sum is N and does not contain any digit as K
- Find the missing digit x from the given expression
- Largest K digit number divisible by X
- Check if the product of digit sum and its reverse equals the number or not
- Special two digit number
- Print multiples of Unit Digit of Given 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
- Largest Even and Odd N-digit numbers in Hexadecimal Number System
- Place Value of a given digit in a number
- Smallest and Largest N-digit number starting and ending with N
- Print the frequency of each character in Alphabetical order
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.