Java program to count number of Digits in the Input

import java.util.Scanner;
class scan
{
 public static void main(String arg[])
 { int x,y=0;
  Scanner kb=new Scanner(System.in);
  System.out.println("Enter Number:-");
  x=kb.nextInt();
  while(x>0)
   {
   x= x/10;
	y++;
	}
System.out.println("Number of digits is:- "+y);
}
}

OUTPUT:-

Leave a Reply

Your email address will not be published. Required fields are marked *