C Program to count the occurence of digit
Sample Input 1 :
6372 3
Sample Output 1 :
3 is occurred in 6373 for 2 times
Try your Solution
Strongly recommended to Solve it on your own, Don't directly go to the solution given below.
#include<stdio.h>
int main()
{
	//write your code here
}
    			
  		
		
		
		Program or Solution
			
				
			
					
#include<stdio.h>
int main()
{
	int n,num,digit,rem,count;
	scanf("%d %d",&num,&digit);
	n=num;
	while(num!=0)
	{
		rem=num%10;
		if(rem==digit)
		{
			count++;	
		}
		num/=10;
	}
	printf("%d is occured in %d for %d times",digit,n,count);
	return 0;
}
		
			
				
			
		
		
					
		
		
								
		Program Explanation
refer video tutorialComments
Related Programs
- C Program to check whether the given digit is occurred in a Number
- C Program to find the first digit of a number
- C Program to Count the digits in the given number.
- C Program to calculate sum of digits.
- C Program to calculate product of digits.
- C Program to reverse the digits of an number
- C Program to check whether given Integer is Palindrome or Not
- C Program to check whether given Integer is Armstrong or Not
                
                coming Soon
                
            
            
                
                coming Soon
            
        
