1. ## Reading in single characters

So I'm working on a program to compute the first positive integer with a numerical persistence of 3 (persistence being the number of times the digits of a number are multiplied together until the product is a single digit ex: 614 -> 6*1*4=24 ->2*4=8, where 8 is the desired single-digit product and the persistence is 2).

The instructions ask for there to be no explicit input, so I assume that it means the program will generate the numbers to evaluate the persistence of (generated by a counter I'm guessing).

What I'm stuck on is how to read the integers created by the counter into my program. When the counter=1, it should be able to read in "1". When the counter gets to 614, it should read in "6" "1" "4", and so on for all the numbers. So far I have only used external data files to read information into programs, and have never read in single digits like this.

Wondering if you guys have any tips on reading in.

My first guesses were to use something like cin.get(integer), but since all the numbers are created in the program... not really what I need.

Thanks for any help
Pallum

2. Since an integer will be passed to you, you don't need to "read in" anything. What you need to do is break up the number you're given into its individual digits.

You can do this using division and modulus. For example,
614%10==4
614/10%10==1
614/100%10==6