Java Program to Count Number of Digits in an Integer - The Coding Shala
In this post, we will learn how to count the number of digits in an integer using a Java program.
Java Program to Count Number of Digits in an Integer
You have given an integer, return the number of digits in that using Java program. The given number is above 0.
When we divide a number by 10, we get one digit or we remove one digit from a given number so here we will be using a loop and divide the given number by 10 until it becomes 0.
The number is 23, so after first iteration
number = 23/10 = 2, and count = 1
second iteration => number = 2/10 = 0, count = 2.
- Java Program to Check Armstrong Number
- Java Program to Check Prime Number
- Java Program to Reverse a Number
- Java Program to Check if a Number is a Palindrome
- Java Program to Print Multiplication Table of any Number