Count the digits in the number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 4

Count the digits in the number

1 5 3 2 1 3 2=7

3rd Sep 2017, 3:38 AM
Babu Raju
Babu Raju - avatar
1 Answer
+ 4
take a number , divide it by 10 , u will lose each digit from the end ie , int x=1234; //u can also take this value using scanner int n=0 while (x !=0) { x/=10; //it will remove last digit form the number n++; } System.out.print(n); now use some logic of ur own ,, & make answer to ur other 2 questions also ..
3rd Sep 2017, 3:57 AM
Changed
Changed - avatar