Q:

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

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Basic Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a C Program to find out the sum of first n n... >>
<< C Program to display sum of even and product of od...