ICSE Class 10 Computer Applications
Question 65 of 76
Revising Basic Java Concepts — Question 69
Back to all questions 69
Question Question 46
Write a program that takes a number and check if the given number is a 3 digit number or not. (Use a loop to determine)
import java.util.Scanner;
public class KboatDigitCount
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
int n = in.nextInt();
int count = 0;
while (n != 0) {
count++;
n = n / 10;
}
if (count == 3)
System.out.println("Three digit number");
else
System.out.println("Not a three digit number");
}
}Output

