Write a C Program to check occurence of digit in a given number

Check occurence of digit in a given number


Write a C Program to check occurence of digit in a given number. Here’s simple Program to check occurence of digit in a given number in C Programming Language.


Below is the source code for C Program to check occurence of digit in a given number which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :


/*  C Program to check occurence of digit in a given number  */

#include<stdio.h>
#include<conio.h>

int main()
{
  int num,i,n,k,num1;
  printf("Enter any number :: ");
  scanf("%d",&num);
  n=num;
  i=0;
  printf("\nEnter the digit :: ");
  scanf("%d",&num1);

  while(n!=0)
  {
  k=n%10;
  n=n/10;
  if(k==num1)
  {
  i++;
  }
  }
  printf("\nThe occurrence of %d is %d times",num1,i);

  return 0;
}

OUTPUT : :


Enter any number :: 443454

Enter the digit :: 4

The occurrence of 4 is 4 times

Above is the source code for C Program to find the roots of quadratic equation which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.


Thanks for reading the post….

Leave a Reply