From e68334330ebc4a64d9d0b09b90c50b03c301c465 Mon Sep 17 00:00:00 2001 From: Utsav1999 Date: Sat, 25 Jul 2020 21:49:11 +0530 Subject: [PATCH] Added Count Digit program --- Maths/CountDigit.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Maths/CountDigit.java diff --git a/Maths/CountDigit.java b/Maths/CountDigit.java new file mode 100644 index 000000000..2c3080e30 --- /dev/null +++ b/Maths/CountDigit.java @@ -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); + } +} \ No newline at end of file