so in those math programs we need the user to input some numbers, right?
but the problem is when he makes a mistake and puts a non-number into an int or float...
How do we prevent him from doing that, but keeping it as simple for the user as possible?
I actually like this FAQ better for this particular problem. It is worth a read. You could use this example to create your own function for asking for input so that you can just call a function and have it return a value after the user finally enters something valid. http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.3
Article 9645 has some similar ideas but was written more to the purpose of converting a string to a number or vice versa.