AedenCak3

Frequency() [Digit counter in input]

Dec 2nd, 2021
746
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. void printFrequency(int n)
  3. {
  4.     int num;
  5.     printf("Enter the digit: ");
  6.     scanf("%d",&num);
  7.     int count=0;
  8.     int x=n;
  9.     while(n!=0)
  10.     {
  11.         int rem=n%10;
  12.         if(rem==num)
  13.         {
  14.             count++;
  15.         }
  16.         n=n/10;
  17.     }
  18.  
  19.     printf("%d has %d times in %d",num,count,x);
  20. }
  21. int main()
  22. {
  23.    int n;
  24.  
  25.    printf("Enter a number: ");
  26.    scanf("%d",&n);
  27.  
  28.     printFrequency(n);
  29.     return 0;
  30. }
  31.  
RAW Paste Data