0

How can i get the Thousands, hundreds, tens, ones, from user input? Using array in C#

4th Jan 2017, 2:09 PM
Joven Patungan
Joven Patungan - avatar
5 Answers
+ 1
public static void split(int n) { if(n<10){ Array.add(arr, n); break; // break is to end this } else{ Array.add(arr, n%10); split(n/10); } } 12376 will give [6,7,3,2,1]
4th Jan 2017, 2:51 PM
Sandeep Chatterjee
+ 1
what is the name array? variable?
4th Jan 2017, 3:02 PM
Joven Patungan
Joven Patungan - avatar
+ 1
for example in 182376 in if 182376>10 so else will work put 182376%10=6 inside arr=[6]; then do same for 18237 now process will repeat and same thing happen with smaller no. so it will make arr=[6,7,3,2,8] now one last digit it is <10 so 1 will be written arr=[6,7,3,2,8,1]
4th Jan 2017, 3:03 PM
Sandeep Chatterjee
+ 1
I changed the name to arr arr is the name of array where values are being added after splitting digits
4th Jan 2017, 3:07 PM
Sandeep Chatterjee
0
what is Array.add? cant find this code. String[] Arr. add is cant find
7th Jan 2017, 3:06 PM
Joven Patungan
Joven Patungan - avatar