Donnie Inman wrote:If it does then won't it select another random number
No. The first part of a for loop is the initialisation step - this is only done once. the value of second will never change after this. So it either gets set to something different from the first number and immediately breaks from the loop or it gets set to the same as the first number and just sits in the loop forever checking if the first value is not equal to the second value.
You need to move the setting of 'second to the last part of the for loop - i.e. after the second ;
You should also move the
test from inside the loop to the second part of the for loop i.e. between the two ;. That way you don't need to use a break which should be avoided if possible.
Although personally, I think a while loop would be better here
Also, if you're going to use a for loop, use all it's capabilities. For the outer loop, using a for loop is correct but change it to
and get rid of