Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

number of digits java

  public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num = input.nextInt();

        int count = 0;

        while (num > 0) {
            num /= 10;
            count++;
        }
        System.out.println("number of digits: " + count);
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #number #digits #java
ADD COMMENT
Topic
Name
8+7 =