 <p>First of all, to check if the number is even just check the modulus by 2, no need to check if the last digit is 2 or 4 or 6 or 8. I would substitute all your checks with <code>next1%2==0</code>, <code>next1%5==0</code> and <code>next1%10==0</code>, also you need to change every <code>cout&lt;&lt;next2</code> to <code>cout&lt;&lt;next1</code> because <code>next2</code> is modulus of 10 of <code>next1</code>. Also as a good practice I suggest you to read Straustrup C++ book to get the basics of C++.</p>