Q:

Java Program to Count Number of Digits using while loop

0

Program to Count Number of Digits using while 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, number = 12344;

        while(number != 0)
        {
            // num = num/10
            number /= 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