Here's is an excerpt from your code :
for(int i = 0; i < 10; i++)
if ( (a > pow(10, 6)) || (a < 1) || (b > pow(10, 6)) || (b < 1) )
for(int i = 0; ((i < 9) && (a < b)); i++)
I have revised the braces and indentation in order to see it more clearly. Do you see the problem?
I am somewhat surprised this even compiles. I use Visual Studio and I have the warning level set to four always and warnings are errors. It would have told me the redefinition of the variable
hides the previous definition.
Try changing the inner loop indexer to be
and see what happens. In other words, make it look like this :
for( int j = 0; ((j < 9) && (a < b)); j++ )
Another thing - the
function is very inefficient and should be avoided for the most part. Especially since it returns a floating point value and you are using it to compare with integers. You would be better off to use a macro definition and revise your loop. Something like this :
#define MAX_VALUE 1000000
if ( (a > MAX_VALUE) || (a < 1) || (b > MAX_VALUE) || (b < 1) )