I could use some help with a program for school in order to do so I need to put the position of the number in array: For example if I introduce 10582 the first position of the array is gonna be 2, the second 8, the third 5, the fourth 0, and the last 1.
Asked
Active
Viewed 32 times
-3
-
*put the position of the number in array* ? – Saurav Sahu Oct 17 '16 at 18:20
-
what do you mean by 10582 and positions, please elaborate. – Sumeet Oct 17 '16 at 18:21
-
Pick a language. c++ is not c is not c++. – πάντα ῥεῖ Oct 17 '16 at 18:21
1 Answers
0
It sounds like what you want is to extract each digit from a number and store them separately.
That being the case, you can use the modulus operator (%
) to get the remainder of dividing by 10. That will give you the rightmost digit. Then you would divide the number by 10 to shift the rightmost decimal digit off.
Repeat the process until you're left with 0.

dbush
- 205,898
- 23
- 218
- 273