mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-23 04:02:13 +08:00
13 lines
404 B
Java
13 lines
404 B
Java
import java.util.*;
|
|
import java.lang.*;
|
|
// count the number of digits in a number
|
|
class CountDigit{
|
|
public static void main(String args[]){
|
|
Scanner sc = new Scanner(System.in);
|
|
System.out.print("Enter the number: ");
|
|
int number = sc.nextInt();
|
|
int digits = 0;
|
|
digits = (int)Math.floor(Math.log10(number) + 1);
|
|
System.out.println("The number of digits present in the number: " + digits);
|
|
}
|
|
} |