We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8ddbed6 + 7f944d9 commit 33b982eCopy full SHA for 33b982e
1 file changed
Maths/CountDigit.java
@@ -0,0 +1,20 @@
1
+import java.util.*;
2
+package Maths;
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
+ if(number == 0)
11
+ {
12
+ System.out.println("The number of digits present in the number: 1");
13
+ }
14
+ else
15
16
+ digits = (int)Math.floor(Math.log10(Math.abs(number)) + 1);
17
+ System.out.println("The number of digits present in the number: " + digits);
18
19
20
+}
0 commit comments