This is a discussion on help on reading within the C++ Programming forums, part of the General Programming Boards category; i'm suppose to enter random numbers and try to read them one by one and print them out etc enter ...

i'm suppose to enter random numbers and try to read them one by one and print them out

etc

enter number : 56124

third number is 1

and last number 4

2. Read them into a string, or character by character.

3. but it has to be done in int format so that i can do some math with it

4. take for example i input random number 54823

i got to read the number here

and do some math to find out how many even number is there here

how do i go about reading the numbers individualy so that i could do some math to each

number alone

between they are all int

5. Let's say the user entered 52314.

If you wanted to work right to left, you could take the remainder after dividing by 10 and that would give you 4. Doing it again would give you 1, then 3, then 2 then 5, and you would then stop because your number remaining would be 0.

If you wanted to work left to right, you could determine, in a loop, the power of 10 the number adheres to. In this case, it would be 10,000. Dividing by 10,000 would give you 5. Then, subtract out 50,000, reduce the power of 10 by one to give yourself 1,000 and divide 2,314 by that. That would give you 2. And, so on.

Todd