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

By | 02.11.2016

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….

4.8 4 votes
Article Rating
Category: Basic Programs C Programming Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Dhruba

This code gives value 0 if the occurrence is greater than or equal 10…. Can it be solved?