0
Program to extract individual digit from a 4 digit number using loop
can someone tell me logic
3 ответов
+ 2
for(int i=0;i<4;i++){
str.charAt(i);
+ 1
turn into a string.Index desired digit.Turn into a int again
You can use Integer.toString() and Integer.parseInt()
0
use a while loop till no. is greater than 0.
in loop: remainder= n% 10
print (remainder)
n = n/10
or you can store these remainders in an array to get in using index value.