Skip to content

Commit e683343

Browse files
committed
Added Count Digit program
1 parent d2870c8 commit e683343

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Maths/CountDigit.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
// count the number of digits in a number
4+
class CountDigit{
5+
public static void main(String args[]){
6+
Scanner sc = new Scanner(System.in);
7+
System.out.print("Enter the number: ");
8+
int number = sc.nextInt();
9+
int digits = 0;
10+
digits = (int)Math.floor(Math.log10(number) + 1);
11+
System.out.println("The number of digits present in the number: " + digits);
12+
}
13+
}

0 commit comments

Comments
 (0)