Is it possible to convert a user inputted 4-digit number such as: '1234' into an array which holds the digits of that number in each index. So for this number it would convert to: [1, 2, 3, 4]. If this is possible, how is it done? Thanks in advance.
Printable View
Is it possible to convert a user inputted 4-digit number such as: '1234' into an array which holds the digits of that number in each index. So for this number it would convert to: [1, 2, 3, 4]. If this is possible, how is it done? Thanks in advance.
What happened when you tried it? Did it work? Was there an error?
We do not provide solutions to problems in code here, see the spoonfeeding policy on the subject.
What we will do is help give suggestions when you get stuck. The suggestion here is to try it. Write a simple program to accept user input and try to do what you have described.
Is the number in a String? Or in an int? Which one you work with will make a big difference in the code.