Q:

Java Program to Count Number of Digits using for loop

0

Java Program to Count Number of Digits using for loop.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

public class demo1 {

    public static void main(String[] args) {

        int count = 0, num = 123456;

        for(; num != 0; num/=10, ++count) {   
        }

        System.out.println("Number of digits: " + count);
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now