Sunday, October 20, 2019

Count the number of Digits of a Number



Program

package digits;

public class Digits
{
    public static void main(String[] args)
    {
        int n = 34243;
        int count = 0;
        while(n > 0)
        {
            n = n / 10;
            count++;
        }
        System.out.println(count);
    }
}

Video explanation


2 comments: