Added Count Digit program

This commit is contained in:
Utsav1999
2020-07-25 21:49:11 +05:30
parent d2870c841d
commit e68334330e

13
Maths/CountDigit.java Normal file
View File

@ -0,0 +1,13 @@
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);
}
}