0

Program to extract individual digit from a 4 digit number using loop

can someone tell me logic

8th Mar 2017, 3:09 PM
Vivian Mascarenhas
Vivian Mascarenhas - avatar
3 Respuestas
+ 2
for(int i=0;i<4;i++){ str.charAt(i);
8th Mar 2017, 3:19 PM
Meharban Singh
Meharban Singh - avatar
+ 1
turn into a string.Index desired digit.Turn into a int again You can use Integer.toString() and Integer.parseInt()
8th Mar 2017, 3:12 PM
fine bug
fine bug - avatar
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.
8th Mar 2017, 3:20 PM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar