Q2. Write a java program to accept a positive integer and count number of digits in it.
Answers
Answered by
2
public class Main {
public static void main(String[] args) {
int count = 0, num = 0003452;
while (num != 0) {
// num = num/10
num /= 10;
++count;
}
System.out.println("Number of digits: " + count);
}
}
I hope it helps u
make me a brilliant
Similar questions
English,
2 months ago
Accountancy,
2 months ago
Math,
2 months ago
History,
4 months ago
Math,
4 months ago
Chemistry,
10 months ago
Psychology,
10 months ago