Write a program using while loop in java to count the number of digits in an unknown number.
Answers
Answered by
9
Answer:
public class NumberDigits {
public static void main(String[] args) {
int count = 0, num = 3452;
while(num != 0)
{
// num = num/10
num /= 10;
++count;
}
System.out.println("Number of digits: " + count);
}
}
Explanation:
hope it helps
Similar questions