Showing posts with label frequency-of-a-digit-in-number. Show all posts
Showing posts with label frequency-of-a-digit-in-number. Show all posts

Monday, July 27, 2020

Write a program to input a numbers and find the frequency of any digit of this number, digit choose by the user. (124443=frequency of 4=3)

50)  Write a program to input a numbers and find the frequency of any digit of this number, digit choose by the user. (124443=frequency of 4=3)


import java.util.*;
public class Frequency_of_a_digit
{
     public static void main(String args[ ])
   {
          Scanner sc = new Scanner (System.in);
          System.out.println("Enter a number");
          int a = sc.nextInt();
          System.out.println("Enter a number of which you need FREQUENCY");
          int b = sc.nextInt();
          int p = a;
          int c = 0;
          while(p>0)
          {
          int d = p%10;
          if(d==b)
          {
          c++;
          }
          p=p/10;
          }
          System.out.println("FREQUENCY of "+b+" in "+a+" = "+c);   
   }
}

Output : 

frequency-of-a-digit-in-number


   Write a program with a special member function to input a multi digit long integer number ( max. 9 digit) and print the following:

1-Total number of Even and Odd digits

2-The Reverse Number

3-Total number of Zero’s present.


 jhvghvgk ;nkjn ,nkjhj