Java Program To Find Number Of Digit From Any Number
Chapter:
Miscellaneous
Last Updated:
25-09-2016 14:10:26 UTC
Program:
/* ............... START ............... */
import java.util.Scanner;
public class JavaNumberOfDigitOfNumber {
public static void main(String[] args) {
int no, a = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter any number : ");
no = scanner.nextInt();
if (no < 0) {
no = no * -1;
} else if (no == 0) {
no = 1;
}
while (no > 0) {
no = no / 10;
a++;
}
System.out.println("Number of Digits in given number is: " + a);
}
}
/* ............... END ............... */
Output
Enter any number :
47477
Number of Digits in given number is: 5
Tags
Find Number Of Digit From Any Number, Java, Miscellaneous