i'm suppose to enter random numbers and try to read them one by one and print them out
etc
enter number : 56124
your first number is 5
third number is 1
and last number 4
how should i go about reading them?
i'm suppose to enter random numbers and try to read them one by one and print them out
etc
enter number : 56124
your first number is 5
third number is 1
and last number 4
how should i go about reading them?
Read them into a string, or character by character.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
but it has to be done in int format so that i can do some math with it
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
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