File tree 1 file changed +18
-17
lines changed
1 file changed +18
-17
lines changed Original file line number Diff line number Diff line change 1
- import java .util .*;
2
1
package Maths ;
2
+
3
+ import java .util .*;
4
+
3
5
// 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
- }
6
+ public class CountDigit {
7
+ public static void main (String args []) {
8
+ Scanner sc = new Scanner (System .in );
9
+ System .out .print ("Enter the number: " );
10
+ int number = sc .nextInt ();
11
+ int digits = 0 ;
12
+ if (number == 0 ){
13
+ System .out .println ("The number of digits present in the number: 1" );
14
+ }
15
+ else
16
+ {
17
+ digits = (int )Math .floor (Math .log10 (Math .abs (number )) + 1 );
18
+ System .out .println ("The number of digits present in the number: " + digits );
19
19
}
20
- }
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments