When you write int age; cin >> age; and the user types twenty, the extraction fails. The variable age remains unchanged, and cin enters an error state with a flag set. Once in error state, all subsequent cin operations fail instantly without reading anything.
If you write cin >> age; cin >> salary; and the first fails, the second also fails immediately. The bad input stays in the buffer, so twenty remains there. If you clear the error with cin.clear() and try reading again, it tries twenty again and fails, creating an infinite loop.